Documente Academic
Documente Profesional
Documente Cultură
)
@ pathname Run an SQL Script (see START) @MyScript.sql parameter1 parameter2 parameter3 In the SQL-Script, refer to the parameters as &1, &2, and &3.
@@ pathname Run a nested SQL Script. / ACCEPT Execute (or re-execute) commands in the SQL*Plus buffer does not list commands before running User input ACC[EPT] variable [NUM[BER]|CHAR|DATE] [FORMAT format] [DEFAULT default] [PROMPT text|NOPROMPT] [HIDE] Add text to the end of the current line in the buffer. A[PPEND] text_to_add Specify where and how formatting will change. BREAK ON {column|expr|ROW|REPORT} action Place and format a title at the bottom of each page. BTITLE printspec [text|variable] BTITLE [OFF|ON] Change text on the current line. C /oldval/newval Clear the SQL*Plus screen and the screen buffer. CLEAR {BREAKS|BUFFER|COLUMNS|COMPUTES|SCREEN|SQL TIMING} Change display width of a column. Calculate and display totals. Connect to a database as a specified user. connect username/password@SID Copy data from a query into a table (local or remote) User variables: DEFINE varName = String Display a user variable DEFINE varName Display all variables DEFINE DEFINE_EDITOR = sql*plus editor (e.g. DEFINE_EDITOR=vim.exe) DEL DESC[RIBE] Delete the current line in the SQL buffer Describe a table, column, view, synonym, function procedure, package or package contents.
DISCONNECT EDIT EXECUTE EXIT [n] GET file HELP topic HOST INPUT LIST n m
Logoff (but don't exit) Load the SQL*Plus buffer into an editor. By default, saves the file to AFIEDT.BUF Run a single PLSQL statement EXEC :answer := EMP_PAY.BONUS('SMITH') Commit, logoff and exit (n = error code) EXIT SQL.SQLCODE Retrieve a previously stored command file Topic is an SQL PLUS command or HELP COMMANDS Execute a host operating system command HOST CD scripts Edit sql buffer - add line(s) to the buffer Edit sql buffer - display buffer lines n to m For all lines - specify m as LAST Wait for the user to hit RETURN List the value of a bind variable or REF Cursor (see Echo a message to the screen or /* comment */
PAUSE message PRINT variable VARIABLE / SHOW) PROMPT message REMARK RUN RUNFORM SAVE file SET SHOW
Execute (or re-execute) commands in the SQL*Plus buffer Lists the commands before running Run a SQL*Forms application Save the contents of the SQL*Plus buffer in a command file SAVE file [CRE[ATE] | REP[LACE] | APP[END]] Display or change SQL*Plus settings List the value of a system variable (see PRINT)
SHUTDOWN [ABORT|IMMEDIATE|NORMAL|TRANSACTIONAL] SPOOL file SPOOL OFF SQLPLUS STA[RT] Store query results in file Turn off spooling SPOOL OUT sends file to printer Start SQL*Plus and connect to a database. Run an SQL Script (see @)
STARTUP [NoMOUNT|MOUNT|OPEN]
Record timing data TIMING {START | SHOW | STOP} see CLEAR TIMING Define a page title Delete a user variable or passed parameter (see DEFINE) Define a bind variable (Can be used in both SQLPlus and PLSQL) VAR[IABLE] [variable {NUMBER|CHAR|CHAR (n)}] VARIABLE on its own will display the definitions made. Exit if an OS error occurs Exit if an SQL or PLSQL error occurs
Primary key:
For example: CREATE TABLE supplier ( supplier_id numeric(10) not null, supplier_name varchar2(50) not null, contact_name varchar2(50), CONSTRAINT supplier_pk PRIMARY KEY (supplier_id) ); In this example, we've created a primary key on the supplier table called supplier_pk. It consists of only one field - the supplier_id field.
We could also create a primary key with more than one field as in the example below: CREATE TABLE supplier ( supplier_id numeric(10) not null, supplier_name varchar2(50) not null, contact_name varchar2(50), CONSTRAINT supplier_pk PRIMARY KEY (supplier_id, supplier_name) );
For example: ALTER TABLE supplier add CONSTRAINT supplier_pk PRIMARY KEY (supplier_id); In this example, we've created a primary key on the existing supplier table called supplier_pk. It consists of the field called supplier_id.
We could also create a primary key with more than one field as in the example below: ALTER TABLE supplier add CONSTRAINT supplier_pk PRIMARY KEY (supplier_id, supplier_name);
For example: ALTER TABLE supplier drop CONSTRAINT supplier_pk; In this example, we're dropping a primary key on the supplier table called supplier_pk.
For example: ALTER TABLE supplier disable CONSTRAINT supplier_pk; In this example, we're disabling a primary key on the supplier table called supplier_pk.
The syntax for enabling a primary key is: ALTER TABLE table_name enable CONSTRAINT constraint_name;
For example: ALTER TABLE supplier enable CONSTRAINT supplier_pk; In this example, we're enabling a primary key on the supplier table called supplier_pk.