Welcome to Oracle Database Administrator Home

24x7 oracle database support and solutions
Oracle DBA Home     Routine Maintenance     PostgreSQL     Unix Commands     CVS     Oracle FAQ     Oracle Concepts     SQLPlus     OEM     ASM     Data Guard     RAC     RMAN     Networking     OAS     Partitioning      
Set SQLplus Prompts
SQLPlus Data Format
HTML using SQLplus
SQLplus Copy Command
AFIEDTBUF
FU SQLplus Commands
OS Variable in SQLPlus
SQL*Plus Commands
A single @ symbol runs a script in the current directory (or one specified with a full or relative path, or one that is found in your SQLPATH or ORACLE_PATH).
@@ will start a sqlplus script that is in the same directory as the script that called it (relative to the directory of the current script). This is normally used for nested command files. This technique is commonly used by scripts that call subscripts in the ?/rdbms/admin directory.

 

Log in to SQL*Plus SQLPLUS [ { username[/passward][@connect_identifier] | / }
[ AS { SYSDBA | SYSOPER } ]
| /NOLOG
]
List help topics available
in SQL*Plus
HELP [ INDEX | topic ]

Capture query results in a
file and, optionally, send
contents of file to default
printer
SPOOL [ filename [ .ext ]
[ CREATE | REPLACE | APPEND | OFF | OUT ]
Run SQL*Plus statements
stored in a file
@ { url | filename [ .ext ] } [ arg... ]
START filename [ .ext ] [ arg... ]
.ext can be omitted if the filename extension is .sql
 

Append text to end of
current line in the SQL
buffer
APPEND text
Find and replace first
occurrence of a text string
in current line of the SQL
buffer
CHANGE sepchar old [ sepchar [ new [ sepchar ] ] ]
sepchar can be any non-alphanumeric character such as "/" or
"!"


ALTER CLUSTER ALTER CLUSTER [ schema. ]cluster
{ physical_attributes_clause
| SIZE size_clause
| allocate_extent_clause
| deallocate_unused_clause
| { CACHE | NOCACHE }
}
[ physical_attributes_clause
| SIZE size_clause
| allocate_extent_clause
| deallocate_unused_clause
| { CACHE | NOCACHE }
]...
[ parallel_clause ] ;
ALTER DATABASE ALTER DATABASE [ database ]
{ startup_clauses
| recovery_clauses
| database_file_clauses
| logfile_clauses
| controlfile_clauses
| standby_database_clauses
| default_settings_clauses
| redo_thread_clauses
| security_clause
} ;
ALTER DIMENSION ALTER DIMENSION [ schema. ]dimension
{ ADD
{ level_clause
| hierarchy_clause
| attribute_clause
| extended_attribute_clause
}
[ ADD
{ level_clause
| hierarchy_clause
| attribute_clause
| extended_attribute_clause
}
]...
| DROP
{ LEVEL level
[ RESTRICT | CASCADE ]
| HIERARCHY hierarchy
| ATTRIBUTE attribute
[ LEVEL level [ COLUMN column
[, COLUMN column ]... ]
}
[ DROP
{ LEVEL level
[ RESTRICT | CASCADE ]
| HIERARCHY hierarchy
| ATTRIBUTE attribute
[ LEVEL level [ COLUMN column
[, COLUMN column ]... ]
}
]...
| COMPILE
} ;
ALTER DISKGROUP ALTER DISKGROUP
{ disk_clauses | diskgroup_clauses }
[ { disk_clauses | diskgroup_clauses } ]... ;
ALTER FUNCTION ALTER FUNCTION [ schema. ]function
COMPILE [ DEBUG ]
[ compiler_parameters_clause
[ compiler_parameters_clause ] ... ]
[ REUSE SETTINGS ] ;

ALTER INDEX ALTER INDEX [ schema. ]index
{ { deallocate_unused_clause
| allocate_extent_clause
| shrink_clause
| parallel_clause
| physical_attributes_clause
| logging_clause
}
[ deallocate_unused_clause
| allocate_extent_clause
| shrink_clause
| parallel_clause
| physical_attributes_clause
| logging_clause
]...
| rebuild_clause
| PARAMETERS ('ODCI_parameters')
| { ENABLE | DISABLE }
| UNUSABLE
| RENAME TO new_name
| COALESCE
| { MONITORING | NOMONITORING } USAGE
| UPDATE BLOCK REFERENCES
| alter_index_partitioning
} ;
ALTER INDEXTYPE ALTER INDEXTYPE [ schema. ]indextype
{ { ADD | DROP }
[ schema. ]operator (parameter_types)
[, { ADD | DROP }
[ schema. ]operator (parameter_types)
]...
[ using_type_clause ]
| COMPILE
} ;
ALTER JAVA ALTER JAVA
{ SOURCE | CLASS } [ schema. ]object_name
[ RESOLVER
( ( match_string [, ] { schema_name | - } )
[ ( match_string [, ] { schema_name | - } )
]...
)
]
{ { COMPILE | RESOLVE }
| invoker_rights_clause
} ;
ALTER MATERIALIZED VIEW ALTER MATERIALIZED VIEW
[ schema. ](materialized_view)
[ physical_attributes_clause
| table_compression
| LOB_storage_clause
[, LOB_storage_clause ]...
| modify_LOB_storage_clause
[, modify_LOB_storage_clause ]...
| alter_table_partitioning
| parallel_clause
| logging_clause
| allocate_extent_clause
| shrink_clause
| { CACHE | NOCACHE }
]
[ alter_iot_clauses ]
[ USING INDEX physical_attributes_clause ]
[ MODIFY scoped_table_ref_constraint
| alter_mv_refresh
]
[ { ENABLE | DISABLE } QUERY REWRITE
| COMPILE
| CONSIDER FRESH
] ;
ALTER MATERIALIZED VIEW LOG ALTER MATERIALIZED VIEW LOG [ FORCE ]
ON [ schema. ]table
[ physical_attributes_clause
| alter_table_partitioning
| parallel_clause
| logging_clause
| allocate_extent_clause
| shrink_clause
| { CACHE | NOCACHE }
]
[ ADD
{ { OBJECT ID
| PRIMARY KEY
| ROWID
| SEQUENCE
}
[ (column [, column ]...) ]
| (column [, column ]... )
}
[, { { OBJECT ID
| PRIMARY KEY
| ROWID
| SEQUENCE
}
[ (column [, column ]...) ]
| (column [, column ]...)
}
]...
[ new_values_clause ]
] ;
ALTER OPERATOR ALTER OPERATOR [ schema. ]operator
{ add_binding_clause
| drop_binding_clause
| COMPILE
} ;
ALTER OUTLINE ALTER OUTLINE
[ PUBLIC | PRIVATE ] outline
{ REBUILD
| RENAME TO new_outline_name
| CHANGE CATEGORY TO new_category_name
| { ENABLE | DISABLE }
}
[ REBUILD
| RENAME TO new_outline_name
| CHANGE CATEGORY TO new_category_name
| { ENABLE | DISABLE }
]... ;
ALTER PACKAGE ALTER PACKAGE [ schema. ]package
COMPILE [ DEBUG ]
[ PACKAGE | SPECIFICATION | BODY ]
[ compiler_parameters_clause
[ compiler_parameters_clause ] ... ]
[ REUSE SETTINGS ] ;
ALTER PROCEDURE ALTER PROCEDURE [ schema. ]procedure
COMPILE [ DEBUG ]
[ compiler_parameters_clause
[ compiler_parameters_clause ] ... ]
[ REUSE SETTINGS ] ;
ALTER PROFILE ALTER PROFILE profile LIMIT
{ resource_parameters | password_parameters }
[ resource_parameters | password_parameters
]... ;
ALTER RESOURCE COST ALTER RESOURCE COST
{ CPU_PER_SESSION
| CONNECT_TIME
| LOGICAL_READS_PER_SESSION
| PRIVATE_SGA
}
integer
[ { CPU_PER_SESSION
| CONNECT_TIME
| LOGICAL_READS_PER_SESSION
| PRIVATE_SGA
}
integer
] ... ;
ALTER ROLE ALTER ROLE role
{ NOT IDENTIFIED
| IDENTIFIED
{ BY password
| USING [ schema. ]package
| EXTERNALLY
| GLOBALLY
}
} ;
ALTER ROLLBACK SEGMENT ALTER ROLLBACK SEGMENT rollback_segment
{ ONLINE
| OFFLINE
| storage_clause
| SHRINK [ TO integer [ K | M ] ]
};
ALTER SEQUENCE ALTER SEQUENCE [ schema. ]sequence
{ INCREMENT BY integer
| { MAXVALUE integer | NOMAXVALUE }
| { MINVALUE integer | NOMINVALUE }
| { CYCLE | NOCYCLE }
| { CACHE integer | NOCACHE }
| { ORDER | NOORDER }
}
[ INCREMENT BY integer
| { MAXVALUE integer | NOMAXVALUE }
| { MINVALUE integer | NOMINVALUE }
| { CYCLE | NOCYCLE }
| { CACHE integer | NOCACHE }
| { ORDER | NOORDER }
]... ;
ALTER SESSION ALTER SESSION
{ ADVISE { COMMIT | ROLLBACK | NOTHING }
| CLOSE DATABASE LINK dblink
| { ENABLE | DISABLE } COMMIT IN PROCEDURE
| { ENABLE | DISABLE } GUARD
| { ENABLE | DISABLE | FORCE } PARALLEL
{ DML | DDL | QUERY } [ PARALLEL integer ]
| { ENABLE RESUMABLE
[ TIMEOUT integer ] [ NAME string ]
| DISABLE RESUMABLE
}
| alter_session_set_clause
} ;

ALTER SYSTEM ALTER SYSTEM
{ archive_log_clause
| checkpoint_clause
| check_datafiles_clause
| DUMP ACTIVE SESSION HISTORY [ MINUTES integer ]
| distributed_recov_clauses
| restricted_session_clauses
| FLUSH { SHARED_POOL | BUFFER_CACHE }
| end_session_clauses
| SWITCH LOGFILE
| { SUSPEND | RESUME }
| quiesce_clauses
| shutdown_dispatcher_clause
| REGISTER
| SET alter_system_set_clause
[ alter_system_set_clause ]...
| RESET alter_system_reset_clause
[ alter_system_reset_clause ]...
} ;
ALTER TABLE ALTER TABLE [ schema. ]table
[ alter_table_properties
| column_clauses
| constraint_clauses
| alter_table_partitioning
| alter_external_table_clauses
| move_table_clause
]
[ enable_disable_clause
| { ENABLE | DISABLE }
{ TABLE LOCK | ALL TRIGGERS }
[ enable_disable_clause
| { ENABLE | DISABLE }
{ TABLE LOCK | ALL TRIGGERS }
]...
] ;

ALTER TABLESPACE ALTER TABLESPACE tablespace
{ DEFAULT
[ table_compression ] storage_clause
| MINIMUM EXTENT integer [ K | M ]
| RESIZE size_clause
| COALESCE
| RENAME TO new_tablespace_name
| { BEGIN | END } BACKUP
| datafile_tempfile_clauses
| tablespace_logging_clauses
| tablespace_group_clause
| tablespace_state_clauses
| autoextend_clause
| flashback_mode_clause
| tablespace_retention_clause
} ;
ALTER TRIGGER ALTER TRIGGER [ schema. ]trigger
{ ENABLE
| DISABLE
| RENAME TO new_name
| COMPILE [ DEBUG ]
[ compiler_parameters_clause
[ compiler_parameters_clause ] ... ]
[ REUSE SETTINGS ]
} ;
ALTER TYPE ALTER TYPE [ schema. ]type
{ compile_type_clause
| replace_type_clause
| { alter_method_spec
| alter_attribute_definition
| alter_collection_clauses
| [ NOT ] { INSTANTIABLE | FINAL }
}
[ dependent_handling_clause ]
} ;
ALTER USER ALTER USER
{ user
{ IDENTIFIED
{ BY password [ REPLACE old_password ]
| EXTERNALLY
| GLOBALLY AS 'external_name'
}
| DEFAULT TABLESPACE tablespace
| TEMPORARY TABLESPACE
{ tablespace | tablespace_group_name }
| QUOTA { integer [ K | M ]
| UNLIMITED
} ON tablespace
[ QUOTA { integer [ K | M ]
| UNLIMITED
} ON tablespace
]...
| PROFILE profile
| DEFAULT ROLE { role [, role ]...
| ALL [ EXCEPT
role [, role ]... ]
| NONE
}
| PASSWORD EXPIRE
| ACCOUNT { LOCK | UNLOCK }
}
[ { IDENTIFIED
{ BY password [ REPLACE old_password ]
| EXTERNALLY
| GLOBALLY AS 'external_name'
}
| DEFAULT TABLESPACE tablespace
| TEMPORARY TABLESPACE
{ tablespace | tablespace_group_name }
| QUOTA { integer [ K | M ]
| UNLIMITED
} ON tablespace
[ QUOTA { integer [ K | M ]
| UNLIMITED
} ON tablespace
]...
| PROFILE profile
| DEFAULT ROLE { role [, role ]...
| ALL [ EXCEPT
role [, role ]... ]
| NONE
}
| PASSWORD EXPIRE
| ACCOUNT { LOCK | UNLOCK }
}
]...
| user [, user ]... proxy_clause ;
ALTER VIEW ALTER VIEW [ schema. ]view
{ ADD out_of_line_constraint
| MODIFY CONSTRAINT constraint
{ RELY | NORELY }
| DROP { CONSTRAINT constraint
| PRIMARY KEY
| UNIQUE (column [, column ]...)
}
| COMPILE
} ;
ANALYZE ANALYZE
{ TABLE [ schema. ]table
[ PARTITION (partition)
| SUBPARTITION (subpartition)
]
| INDEX [ schema. ]index
[ PARTITION (partition)
| SUBPARTITION (subpartition)
]
| CLUSTER [ schema. ]cluster
}
{ validation_clauses
| LIST CHAINED ROWS [ into_clause ]
| DELETE [ SYSTEM ] STATISTICS
| compute_statistics_clause
| estimate_statistics_clause
} ;
ASSOCIATE STATISTICS ASSOCIATE STATISTICS WITH
{ column_association | function_association } ;
AUDIT AUDIT
{ sql_statement_clause | schema_object_clause }
[ BY { SESSION | ACCESS } ]
[ WHENEVER [ NOT ] SUCCESSFUL ] ;
CALL CALL
{ routine_clause
| object_access_expression
}
[ INTO :host_variable
[ [ INDICATOR ] :indicator_variable ] ] ;
COMMENT COMMENT ON
{ TABLE [ schema. ]
{ table | view }
| COLUMN [ schema. ]
{ table. | view. | materialized_view. } column
| OPERATOR [ schema. ] operator
| INDEXTYPE [ schema. ] indextype
| MATERIALIZED VIEW materialized_view
}
IS 'text' ;

Execute host commands HOST [ command ]
Show SQL*Plus system
variables or environment
settings
SHOW { ALL | ERRORS | USER | system_variable | ... }
Alter SQL*Plus system
variables or environment
settings
SET system_variable value
Start up a database STARTUP PFILE = filename
[ MOUNT [ dbname ] | NOMOUNT | ... ]
Connect to a database CONNECT [ [ username [ /password ] [ @connect_identifier ]
[ / AS { SYSOPER | SYSDBA } ]
]
List column definitions for
a table, view, or synonym,
or specifications for a
function or procedure
DESCRIBE [ schema. ] object
Edit contents of the SQL
buffer or a file
EDIT [ filename [ .ext ] ]
Get a file and load its
contents into the SQL
buffer
GET filename [ .ext ] [ LIST | NOLLIST ]
Save contents of the SQL
buffer to a file
SAVE filename [ .ext ] [ CREATE | REPLACE | APPEND ]
List contents of the SQL
buffer
LIST [ n | n m | n LAST | ... ]
Delete contents of the SQL
buffer
DEL [ n | n m | n LAST | ... ]


COMMIT COMMIT [ WORK ]
[ COMMENT 'text'
| FORCE 'text' [, integer ]
] ;
CREATE CLUSTER CREATE CLUSTER [ schema. ]cluster
(column datatype [ SORT ]
[, column datatype [ SORT ] ]...
)
[ { physical_attributes_clause
| SIZE size_clause
| TABLESPACE tablespace
| { INDEX
| [ SINGLE TABLE ]
HASHKEYS integer [ HASH IS expr ]
}
}
[ physical_attributes_clause
| SIZE size_clause
| TABLESPACE tablespace
| { INDEX
| [ SINGLE TABLE ]
HASHKEYS integer [ HASH IS expr ]
}
]...
]
[ parallel_clause ]
[ NOROWDEPENDENCIES | ROWDEPENDENCIES ]
[ CACHE | NOCACHE ] ;
CREATE CONTEXT CREATE [ OR REPLACE ] CONTEXT namespace
USING [ schema. ] package
[ INITIALIZED { EXTERNALLY | GLOBALLY }
| ACCESSED GLOBALLY
] ;
CREATE CONTROLFILE CREATE CONTROLFILE
[ REUSE ]
[ SET ]
DATABASE database
[ logfile_clause ]
{ RESETLOGS | NORESETLOGS }
[ DATAFILE file_specification
[, file_specification ]... ]
[ { MAXLOGFILES integer
| MAXLOGMEMBERS integer
| MAXLOGHISTORY integer
| MAXDATAFILES integer
| MAXINSTANCES integer
| { ARCHIVELOG | NOARCHIVELOG }
| FORCE LOGGING
}
[ MAXLOGFILES integer
| MAXLOGMEMBERS integer
| MAXLOGHISTORY integer
| MAXDATAFILES integer
| MAXINSTANCES integer
| { ARCHIVELOG | NOARCHIVELOG }
| FORCE LOGGING
]...
]
[ character_set_clause ] ;
CREATE DATABASE CREATE DATABASE [ database ]
{ USER SYS IDENTIFIED BY password
| USER SYSTEM IDENTIFIED BY password
| CONTROLFILE REUSE
| MAXDATAFILES integer
| MAXINSTANCES integer
| CHARACTER SET charset
| NATIONAL CHARACTER SET charset
| SET DEFAULT
{ BIGFILE | SMALLFILE } TABLESPACE
| database_logging_clauses
| tablespace_clauses
| set_time_zone_clause
}... ;

CREATE DATABASE LINK CREATE [ SHARED ] [ PUBLIC ] DATABASE LINK dblink
[ CONNECT TO
{ CURRENT_USER
| user IDENTIFIED BY password
[ dblink_authentication ]
}
| dblink_authentication
]
[ USING 'connect_string' ] ;
CREATE DIMENSION CREATE DIMENSION [ schema. ]dimension
level_clause
[ level_clause ]...
{ hierarchy_clause
| attribute_clause
| extended_attribute_clause
}
[ hierarchy_clause
| attribute_clause
| extended_attribute_clause
]... ;
CREATE DIRECTORY CREATE [ OR REPLACE ] DIRECTORY directory
AS 'path_name' ;
CREATE DISKGROUP CREATE DISKGROUP diskgroup_name
[ { HIGH | NORMAL | EXTERNAL } REDUNDANCY ]
[ FAILGROUP failgroup_name ]
DISK qualified_disk_clause
[, qualified_disk_clause ]...
[ [ FAILGROUP failgroup_name ]
DISK qualified_disk_clause
[, qualified_disk_clause ]...
]... ;
CREATE FUNCTION CREATE [ OR REPLACE ] FUNCTION [ schema. ]function
[ (argument [ IN | OUT | IN OUT ]
[ NOCOPY ] datatype
[, argument [ IN | OUT | IN OUT ]
[ NOCOPY ] datatype
]...
)
]
RETURN datatype
[ { invoker_rights_clause
| DETERMINISTIC
| parallel_enable_clause
}
[ invoker_rights_clause
| DETERMINISTIC
| parallel_enable_clause
]...
]
{ { AGGREGATE | PIPELINED }
USING [ schema. ]implementation_type
| [ PIPELINED ]
{ IS | AS }
{ pl/sql_function_body | call_spec }
} ;
CREATE INDEX CREATE [ UNIQUE | BITMAP ] INDEX [ schema. ]index
ON { cluster_index_clause
| table_index_clause
| bitmap_join_index_clause
} ;
CREATE INDEXTYPE CREATE [ OR REPLACE ] INDEXTYPE
[ schema. ]indextype FOR
[ schema. ]operator (paramater_type
[, paramater_type ]...)
[, [ schema. ]operator (paramater_type
[, paramater_type ]...)
]...
using_type_clause ;
CREATE JAVA CREATE [ OR REPLACE ]
[ AND { RESOLVE | COMPILE } ]
[ NOFORCE ]
JAVA { { SOURCE | RESOURCE }
NAMED [ schema. ]primary_name
| CLASS [ SCHEMA schema ]
}
[ invoker_rights_clause ]
[ RESOLVER
((match_string [,] { schema_name | - })
[ (match_string [,] { schema_name | - }) ]...
)
]
{ USING { BFILE (directory_object_name ,
server_file_name)
| { CLOB | BLOB | BFILE }
subquery
| 'key_for_BLOB'
}
| AS source_text
} ;
CREATE LIBRARY CREATE [ OR REPLACE ] LIBRARY [ schema. ]libname
{ IS | AS } 'filename' [ AGENT 'agent_dblink' ] ;
CREATE MATERIALIZED VIEW CREATE MATERIALIZED VIEW
[ schema. ]materialized_view
[ OF [ schema. ]object_type ]
[ (scoped_table_ref_constraint) ]
{ ON PREBUILT TABLE
[ { WITH | WITHOUT } REDUCED PRECISION ]
| physical_properties materialized_view_props
}
[ USING INDEX
[ physical_attributes_clause
| TABLESPACE tablespace
]
[ physical_attributes_clause
| TABLESPACE tablespace
]...
| USING NO INDEX
]
[ create_mv_refresh ]
[ FOR UPDATE ]
[ { DISABLE | ENABLE }
QUERY REWRITE
]
AS subquery ;
CREATE MATERIALIZED VIEW
LOG
CREATE MATERIALIZED VIEW LOG
ON [ schema. ] table
[ physical_attributes_clause
| TABLESPACE tablespace
| logging_clause
| { CACHE | NOCACHE }
[ physical_attributes_clause
| TABLESPACE tablespace
| logging_clause
| { CACHE | NOCACHE }
]...
]
[ parallel_clause ]
[ table_partitioning_clauses ]
[ WITH { OBJECT ID
| PRIMARY KEY
| ROWID
| SEQUENCE
| (column [, column ]...)
}
[, { OBJECT ID
| PRIMARY KEY
| ROWID
| SEQUENCE
| (column [, column ]...)
}
]...
[ new_values_clause ]
] ;
CREATE OPERATOR CREATE [ OR REPLACE ] OPERATOR
[ schema. ] operator binding_clause ;
CREATE OUTLINE CREATE [ OR REPLACE ]
[ PUBLIC | PRIVATE ] OUTLINE [ outline ]
[ FROM [ PUBLIC | PRIVATE ] source_outline ]
[ FOR CATEGORY category ]
[ ON statement ] ;
CREATE PACKAGE CREATE [ OR REPLACE ] PACKAGE [ schema. ]package
[ invoker_rights_clause ]
{ IS | AS } pl/sql_package_spec ;
CREATE PACKAGE BODY CREATE [ OR REPLACE ] PACKAGE BODY
[ schema. ]package
{ IS | AS } pl/sql_package_body ;
CREATE PFILE CREATE PFILE [= 'pfile_name' ]
FROM SPFILE [= 'spfile_name'] ;
CREATE PROCEDURE CREATE [ OR REPLACE ] PROCEDURE [ schema. ]procedure
[ (argument [ IN | OUT | IN OUT ]
[ NOCOPY ]
datatype
[, argument [ IN | OUT | IN OUT ]
[ NOCOPY ]
datatype
]...
)
]
[ invoker_rights_clause ]
{ IS | AS }
{ pl/sql_subprogram_body | call_spec } ;
CREATE PROFILE CREATE PROFILE profile
LIMIT { resource_parameters
| password_parameters
}
[ resource_parameters
| password_parameters
]... ;
CREATE ROLE CREATE ROLE role
[ NOT IDENTIFIED
| IDENTIFIED { BY password
| USING [ schema. ] package
| EXTERNALLY
| GLOBALLY
}
] ;
CREATE ROLLBACK SEGMENT CREATE [ PUBLIC ] ROLLBACK SEGMENT rollback_segment
[ { TABLESPACE tablespace | storage_clause }
[ TABLESPACE tablespace | storage_clause ]...
];
CREATE SCHEMA CREATE SCHEMA AUTHORIZATION schema
{ create_table_statement
| create_view_statement
| grant_statement
}
[ create_table_statement
| create_view_statement
| grant_statement
]... ;
CREATE SEQUENCE CREATE SEQUENCE [ schema. ]sequence
[ { INCREMENT BY | START WITH } integer
| { MAXVALUE integer | NOMAXVALUE }
| { MINVALUE integer | NOMINVALUE }
| { CYCLE | NOCYCLE }
| { CACHE integer | NOCACHE }
| { ORDER | NOORDER }
]
[ { INCREMENT BY | START WITH } integer
| { MAXVALUE integer | NOMAXVALUE }
| { MINVALUE integer | NOMINVALUE }
| { CYCLE | NOCYCLE }
| { CACHE integer | NOCACHE }
| { ORDER | NOORDER }
]... ;
CREATE SPFILE CREATE SPFILE [= 'spfile_name' ]
FROM PFILE [= 'pfile_name' ] ;
CREATE SYNONYM CREATE [ OR REPLACE ] [ PUBLIC ] SYNONYM
[ schema. ]synonym
FOR [ schema. ]object [ @ dblink ] ;
CREATE TABLE { relational_table | object_table | XMLType_table }
CREATE TABLESPACE CREATE
[ BIGFILE | SMALLFILE ]
{ permanent_tablespace_clause
| temporary_tablespace_clause
| undo_tablespace_clause
} ;
CREATE TRIGGER CREATE [ OR REPLACE ] TRIGGER [ schema. ]trigger
{ BEFORE | AFTER | INSTEAD OF }
{ dml_event_clause
| { ddl_event [ OR ddl_event ]...
| database_event [ OR database_event ]...
}
ON { [ schema. ]SCHEMA
| DATABASE
}
}
[ WHEN (condition) ]
{ pl/sql_block | call_procedure_statement } ;
CREATE TYPE { create_incomplete_type
| create_object_type
| create_varray_type
| create_nested_table_type
}
CREATE TYPE BODY CREATE [ OR REPLACE ] TYPE BODY [ schema. ]type_name
{ IS | AS }
{ subprogram_declaration
| map_order_func_declaration
}
[, { subprogram_declaration
| map_order_func_declaration
}
]...
END ;

CREATE USER CREATE USER user
IDENTIFIED { BY password
| EXTERNALLY
| GLOBALLY AS 'external_name'
}
[ DEFAULT TABLESPACE tablespace
| TEMPORARY TABLESPACE
{ tablespace | tablespace_group_name }
| QUOTA { integer [ K | M ]
| UNLIMITED
}
ON tablespace
[ QUOTA { integer [ K | M ]
| UNLIMITED
}
ON tablespace
]...
| PROFILE profile
| PASSWORD EXPIRE
| ACCOUNT { LOCK | UNLOCK }
[ DEFAULT TABLESPACE tablespace
| TEMPORARY TABLESPACE
{ tablespace | tablespace_group_name }
| QUOTA { integer [ K | M ]
| UNLIMITED
}
ON tablespace
[ QUOTA { integer [ K | M ]
| UNLIMITED
}
ON tablespace
]...
| PROFILE profile
| PASSWORD EXPIRE
| ACCOUNT { LOCK | UNLOCK }
]...
] ;
CREATE VIEW CREATE [ OR REPLACE ] [ [ NO ] FORCE ] VIEW
[ schema. ]view
[ (alias [ inline_constraint
[ inline_constraint ]... ]
| out_of_line_constraint
[, alias [ inline_constraint
[ inline_constraint ]... ]
| out_of_line_constraint
]...
)
| object_view_clause
| XMLType_view_clause
]
AS subquery [ subquery_restriction_clause ] ;

 

Shut down a database SHUTDOWN [ ABORT | IMMEDIATE | NORMAL | ... ]
Log out of SQL*Plus { EXIT | QUIT }
[ SUCCESS | FAILURE | WARNING | ... ]
[ COMMIT | ROLLBACK ]

 

Disconnect from a
database
DISCONNECT

Execute commands stored
in the SQL buffer
/
List and execute
commands stored in the
SQL buffer
RUN
Execute a single PL/SQL
statement or run a stored
procedure
EXECUTE statement

Add new lines following
current line in the SQL
buffer
INPUT [ text ]

 


DELETE DELETE [ hint ]
[ FROM ]
{ dml_table_expression_clause
| ONLY (dml_table_expression_clause)
}
[ t_alias ]
[ where_clause ]
[ returning_clause ] ;
DISASSOCIATE STATISTICS DISASSOCIATE STATISTICS FROM
{ COLUMNS [ schema. ]table.column
[, [ schema. ]table.column ]...
| FUNCTIONS [ schema. ]function
[, [ schema. ]function ]...
| PACKAGES [ schema. ]package
[, [ schema. ]package ]...
| TYPES [ schema. ]type
[, [ schema. ]type ]...
| INDEXES [ schema. ]index
[, [ schema. ]index ]...
| INDEXTYPES [ schema. ]indextype
[, [ schema. ]indextype ]...
}
[ FORCE ] ;
DROP CLUSTER DROP CLUSTER [ schema. ]cluster
[ INCLUDING TABLES [ CASCADE CONSTRAINTS ] ] ;
DROP CONTEXT DROP CONTEXT namespace ;
DROP DATABASE DROP DATABASE ;
DROP DATABASE LINK DROP [ PUBLIC ] DATABASE LINK dblink ;
DROP DIMENSION DROP DIMENSION [ schema. ]dimension ;
DROP DIRECTORY DROP DIRECTORY directory_name ;
DROP DISKGROUP DROP DISKGROUP diskgroup_name
[ { INCLUDING | EXCLUDING }
CONTENTS
] ;
DROP FUNCTION DROP FUNCTION [ schema. ]function_name ;
DROP INDEX DROP INDEX [ schema. ]index [ FORCE ] ;
DROP INDEXTYPE DROP INDEXTYPE [ schema. ]indextype [ FORCE ] ;
DROP JAVA DROP JAVA
{ SOURCE | CLASS | RESOURCE }
[ schema. ]object_name ;
DROP LIBRARY DROP LIBRARY library_name ;
DROP MATERIALIZED VIEW DROP MATERIALIZED VIEW
[ schema. ]materialized_view
[ PRESERVE TABLE ] ;
DROP MATERIALIZED VIEW LOG DROP MATERIALIZED VIEW LOG
ON [ schema. ]table ;
DROP OPERATOR DROP OPERATOR [ schema. ]operator [ FORCE ] ;
DROP OUTLINE DROP OUTLINE outline ;
DROP PACKAGE DROP PACKAGE [ BODY ] [ schema. ]package ;
DROP PROCEDURE DROP PROCEDURE [ schema. ]procedure ;
DROP PROFILE DROP PROFILE profile [ CASCADE ] ;
DROP ROLE DROP ROLE role ;
DROP ROLLBACK SEGMENT DROP ROLLBACK SEGMENT rollback_segment ;
DROP SEQUENCE DROP SEQUENCE [ schema. ]sequence_name ;
DROP SYNONYM DROP [ PUBLIC ] SYNONYM [ schema. ]synonym
[ FORCE ] ;
DROP TABLE DROP TABLE [ schema. ]table
[ CASCADE CONSTRAINTS ]
[ PURGE ] ;

DROP TABLESPACE DROP TABLESPACE tablespace
[ INCLUDING CONTENTS [ AND DATAFILES ]
[ CASCADE CONSTRAINTS ]
] ;
DROP TRIGGER DROP TRIGGER [ schema. ]trigger ;
DROP TYPE DROP TYPE [ schema. ]type_name
[ FORCE | VALIDATE ] ;
DROP TYPE BODY DROP TYPE BODY [ schema. ]type_name ;
DROP USER DROP USER user [ CASCADE ] ;
DROP VIEW DROP VIEW [ schema. ] view
[ CASCADE CONSTRAINTS ] ;
EXPLAIN PLAN EXPLAIN PLAN
[ SET STATEMENT_ID = 'text' ]
[ INTO [ schema. ]table [ @ dblink ] ]
FOR statement ;
FLASHBACK DATABASE FLASHBACK [ STANDBY ] DATABASE [ database ]
{ TO { SCN | TIMESTAMP } expr
| TO BEFORE { SCN | TIMESTAMP } expr
};
FLASHBACK TABLE FLASHBACK TABLE
[ schema. ]table
[, [ schema. ]table ]...
TO { { SCN | TIMESTAMP } expr
[ { ENABLE | DISABLE } TRIGGERS ]
| BEFORE DROP [ RENAME TO table ]
} ;
GRANT GRANT { grant_system_privileges
| grant_object_privileges
} ;
INSERT INSERT [ hint ]
{ single_table_insert | multi_table_insert } ;
LOCK TABLE LOCK TABLE
[ schema. ] { table | view }
[ { PARTITION (partition)
| SUBPARTITION (subpartition)
}
| @ dblink
]
[, [ schema. ] { table | view }
[ { PARTITION (partition)
| SUBPARTITION (subpartition)
}
| @ dblink
]
]...
IN lockmode MODE
[ NOWAIT ] ;
MERGE MERGE [ hint ]
INTO [ schema. ]table [ t_alias ]
USING [ schema. ] { table | view | subquery }
[ t_alias ]
ON ( condition )
[ merge_update_clause ]
[ merge_insert_clause ] ;
NOAUDIT NOAUDIT
{ sql_statement_clause
[, sql_statement_clause ]...
| schema_object_clause
[, schema_object_clause ]...
}
[ WHENEVER [ NOT ] SUCCESSFUL ] ;
PURGE PURGE
{ { TABLE table
| INDEX index
}
| { RECYCLEBIN | DBA_RECYCLEBIN }
| TABLESPACE tablespace
[ USER user ]
} ;
RENAME RENAME old_name
TO new_name ;
REVOKE REVOKE { revoke_system_privileges
| revoke_object_privileges
} ;
ROLLBACK ROLLBACK [ WORK ]
[ TO [ SAVEPOINT ] savepoint
| FORCE 'text'
] ;
SAVEPOINT SAVEPOINT savepoint ;
SELECT subquery [ for_update_clause ] ;
SET CONSTRAINT[S] SET { CONSTRAINT | CONSTRAINTS }
{ constraint [, constraint ]...
| ALL
}
{ IMMEDIATE | DEFERRED } ;
SET ROLE SET ROLE
{ role [ IDENTIFIED BY password ]
[, role [ IDENTIFIED BY password ] ]...
| ALL [ EXCEPT role [, role ]... ]
| NONE
} ;
SET TRANSACTION SET TRANSACTION
{ { READ { ONLY | WRITE }
| ISOLATION LEVEL
{ SERIALIZABLE | READ COMMITTED }
| USE ROLLBACK SEGMENT rollback_segment
}
[ NAME 'text' ]
| NAME 'text'
} ;
TRUNCATE TRUNCATE
{ TABLE [ schema. ]table
[ { PRESERVE | PURGE } MATERIALIZED VIEW LOG ]
| CLUSTER [ schema. ]cluster
}
[ { DROP | REUSE } STORAGE ] ;
UPDATE UPDATE [ hint ]
{ dml_table_expression_clause
| ONLY (dml_table_expression_clause)
}
[ t_alias ]
update_set_clause
[ where_clause ]
[ returning_clause ] ;

 

 


From Oracle 10g SQL*Plus will attempt to execute glogin.sql and login.sql after each successful connection. This is handy if you want to change the sqlprompt to include the current user. Here is an example (g)login.sql file:
prompt Loading login.sql file...
set sqlprompt "&&_USER@&&_CONNECT_IDENTIFIER SQL>"
define _editor=vi
The following example scripts can be used to include the connected username and database name into the prompt:
set sqlprompt "_USER'@'_CONNECT_IDENTIFIER _PRIVILEGE> "
 
SQL*Plus tries to format data from the database into a human friendly format. This formatting can be disabled by issuing the following SET commands:
SET ECHO OFF
SET NEWPAGE 0
SET SPACE 0
SET PAGESIZE 0
SET FEEDBACK OFF
SET HEADING OFF
SET TRIMSPOOL ON
SET TAB OFF
 
The SQL*Plus COPY command is one of the fastest ways of copying data between databases and schemas. This is also one of the few methods that will handle LONG columns correctly. Look at this example:
SQL> COPY FROM scott/tiger@db1 TO scott/tiger@db2 INSERT mytable USING select * from mytable;
 
One can generate static HTML pages from SQL*Plus (8.1.6 and above) by setting the MARKUP option to HTML ON. This can be done by specifying -MARKUP "HTML ON" from command line, or with the "SET MARKUP HTML ON" command. Look at this example SQL Script:
set markup HTML on
spool index.html
select * from tab;
spool off
set markup HTML off
 
 
AFIEDT.BUF is the SQL*Plus default edit save file. When you issue the command "ed" or "edit" without arguments, the last SQL or PL/SQL command will be saved to a file called AFIEDT.BUF and opened in the default editor.
In the prehistoric days when SQL*Plus was called UFI (User Friendly Interface) this file was named "ufiedt.buf", short for UFI editing buffer. When new features were added to UFI, it was the initially named Advanced UFI and the filename was changed to "aufiedt.buf" and then to "afiedt.buf". They presumably needed to keep the name short for compatibility with some of the odd operating systems that Oracle supported in those days. The name "Advanced UFI" was never used officially, as the name was changed to SQL*Plus before this version was released.
You can overwrite the default edit save file's name like this:
SET EDITFILE "afiedt.buf"
 
 
Here is a list of some of the most frequently used SQL*Plus commands:
ACCEPT - Get input from the user
DEFINE - Declare a variable (short: DEF)
DESCRIBE - Lists the attributes of tables and other objects (short: DESC)
EDIT - Places you in an editor so you can edit a SQL command (short: ED)
EXIT or QUIT - Disconnect from the database and terminate SQL*Plus
GET - Retrieves a SQL file and places it into the SQL buffer
HOST - Issue an operating system command (short: !)
LIST - Displays the last command executed/ command in the SQL buffer (short: L)
PROMPT - Display a text string on the screen. Eg prompt Hello World!!!
RUN - List and Run the command stored in the SQL buffer (short: /)
SAVE - Saves command in the SQL buffer to a file. Eg "save x" will create a script file called x.sql
SET - Modify the SQL*Plus environment eg. SET PAGESIZE 23
SHOW - Show environment settings (short: SHO). Eg SHOW ALL, SHO PAGESIZE etc.
SPOOL - Send output to a file. Eg "spool x" will save STDOUT to a file called x.lst
START - Run a SQL script file (short: @)
 
 
One can pass operating system variables to sqlplus using this syntax:
sqlplus username/password @cmdfile.sql var1 var2 var3
Parameter var1 will be mapped to SQL*Plus variable &1, var2 to &2, etc. Look at this example:
sqlplus scott/tiger @x.sql  '"test parameter"' dual
Where x.sql consists of:
select '&1' from &2;
exit 5;
Info received from Tim Kessler:
Since I occasionally get useful info from your side I felt it is appropriate to add the following:
Example passing the Windows User's Temp Path Location to sqlplus:
sqlplus username/password @cmdfile.sql %TEMP%
within @cmdfile.sql -
SPOOL &1\myscript.log
-- Your script commands
SPOOL OFF