Chapter Contents |
Previous |
Next |
Doing More with SAS/ASSIST Software |
Entering an SQL Query |
A message appears at the top of the SQL Editor window to indicate which SQL is being used. If you need to use a different set of tables, you can create a new Query Manager or talk to your SAS Support Consultant or database administrator (DBA).
You can enter an SQL query in the SQL Editor window if you already know the libref or creator, table, and column names that you want to use.(footnote 1) The SQL Editor window is a complete editor with the following rules:
You can insert or delete lines in the window by using items in the Edit menu.
The query in the following display retrieves the average number of delayed flights each day.
SQL Editor Window With Query
You can now edit the query further or run it by selecting Submit from the Run menu. If you run the query, you can save your output to a SAS or DB2 table, as described in Creating New Tables.
Entering Non-SELECT SQL Code |
You can enter several non-SELECT SQL statements at one time, separated by semicolons. Do not end the final statement with a semicolon.
Note: Using more than one statement and
semicolons applies only to non-SELECT SQL statements and not to SQL queries.
Select New from the File menu to clear the SQL Editor window. Then enter your SQL code into the window. For example,
create index jobcode on airline.jobcde2|jobcode); drop table airline.temp
Select Submit from the Run menu to submit the code to the SAS System or to DB2.
The following list includes some non-Select SQL statements that you might want to submit to your database.
CREATE | creates a table, view, index, or other objects, depending on how the statement is specified. |
DELETE | deletes one or more rows from a table. |
DROP | deletes a table, view, index, or other objects, depending on how the statement is specified. |
INSERT | adds one or more rows to a table. |
UPDATE | modifies the data in columns of a row in a table. |
GRANT | gives users the authority to access or modify objects such as tables or views. (DB2 SQL only) |
REVOKE | revokes the privileges that were given to users by the GRANT statement. (DB2 SQL only) |
For more information and restrictions on these and other SQL statements, see your SQL documentation.
You can use the prompt facility to display a prompt window when non-SELECT SQL statements are submitted. See Using the Prompt Facility for more information. Non-SELECT SQL statements can be saved to and executed from the Result Manager window. See Saving SQL Code or Output and Doing More with Results for information.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.