Detailed ORACLE and SQL Commands PDF
Detailed ORACLE and SQL Commands PDF
Oracle Components
I. Oracle DBMS
A. Oracle Display System (ODS) - activities in the system displayed on the system console.
C. After Image Journaling (AIJ) - program for journaling each change to data in case of need for
recovery.
E. IOR - program for start and stopping ORACLE system for the DBA. This contains the setups
and saves.
II. Pro*SQL - host language interface - group of subroutines which translates SQL statements into machine
code.
B. Report generator - procedural language that creates a report from the data base.
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 1/21
14/04/2018 Detailed ORACLE and SQL commands
VI. Audit- Trail - enables DBA to monitor activities in system for security or tuning purposes.
SQL*PLUS COMMANDS
@ @@ /
WHENEVER SQLERROR
RETURN Statement
SQL COMMANDS
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 2/21
14/04/2018 Detailed ORACLE and SQL commands
DROP PROCEDURE
DROP PROFILE
DELETE
EXPLAIN PLAN
INSERT
LOCK TABLE
SELECT
COMMIT
ROLLBACK
SAVEPOINT
SET TRANSACTION
ALTER SESSION
SET ROLE
ALTER SYSTEM
Insert Command
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 4/21
14/04/2018 Detailed ORACLE and SQL commands
VALUES(value, value,...);
INSERT adds rows to the table or view specified. Names in the column
list may be in any order. Unlisted columns are set to NULL; you must
list any column created NOT NULL, and supply a value for it.
VALUES inserts each item in its list of values into the corresponding
the two lists must be compatible or convertible. CHAR and DATE values
Use a subquery to INSERT rows from another table. SELECT must return
Update Command
WHERE_clause;
must return at least one row, and every column to the left of the =
sign. SELECT may not contain an INTO clause. Use the WHERE clause
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 5/21
14/04/2018 Detailed ORACLE and SQL commands
DELETE removes one or more rows from the table or view you specify.
The WHERE clause specifies the rows to remove. To remove all rows,
SELECT command
PURPOSE:
SYNTAX:
| expr [c_alias] }
[WHERE condition ]
where:
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 6/21
14/04/2018 Detailed ORACLE and SQL commands
DISTINCT
Duplicate rows are those with matching values for each expression in
ALL
table.*
view.*
snapshot.*
You can use the schema qualifier to select from a table, view, or
If you are using Trusted ORACLE, the * does not select the ROWLABEL
expr
in this list can only contain be qualified with schema if the table,
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 7/21
14/04/2018 Detailed ORACLE and SQL commands
c_alias
provides a different name for the column expression and causes the
schema
table
view
snapshot
selected.
dblink
If you omit dblink, ORACLE assumes that the table, view, or snapshot
t_alias
provides a different name for the table, view, or snapshot for the
WHERE
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 8/21
14/04/2018 Detailed ORACLE and SQL commands
TRUE. If you omit this clause, ORACLE returns all rows from the
START WITH
CONNECT BY
GROUP BY
groups the selected rows based on the value of expr for each row and
HAVING
restricts the groups of rows returned to those groups for which the
UNION
UNION ALL
INTERSECT
MINUS
operation.
ORDER BY
expr
FROM clause.
position
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 9/21
14/04/2018 Detailed ORACLE and SQL commands
ASC
DESC
is the default.
FOR UPDATE
NOWAIT
row that is locked by another user. If you omit this clause, ORACLE
waits until the row is available and then returns the results of the
SELECT statement.
PREREQUISITES:
For you to select rows from the base tables of a view, the owner of
the schema containing the view must have SELECT privilege on the
base tables. Also, if the view is in a schema other than your own,
The SELECT ANY TABLE system privilege also allows you to select data
If you are using Trusted ORACLE in DBMS MAC mode, your DBMS label
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 10/21
14/04/2018 Detailed ORACLE and SQL commands
SEE:
DELETE, UPDATE
PURPOSE:
this information:
* column definitions
* integrity constraints
* storage characteristics
* an optional cluster
SYNTAX:
| table_constraint}
| table_constraint} ]...)
[TABLESPACE tablespace]
[STORAGE storage_clause]
[ ENABLE enable_clause
[AS subquery]
where:
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 11/21
14/04/2018 Detailed ORACLE and SQL commands
schema
table
column
datatype
DEFAULT
INSERT statement omits a value for the column. The datatype of the
column_constraint
table_constraint
PCTFREE
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 12/21
14/04/2018 Detailed ORACLE and SQL commands
default value is 10. This value reserves 10% of each block for
PCTFREE has the same function in the commands that create and alter
PCTUSED
for each data block of the table. A block becomes a candidate for
row insertion when its used space falls below PCTUSED. PCTUSED is
PCTUSED has the same function in the commands that create and alter
The sum of PCTFREE and PCTUSED must be less than 100. You can use
efficiently.
INITRANS
each data block allocated to the table. This value can range from 1
operating system.
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 13/21
14/04/2018 Detailed ORACLE and SQL commands
transactions can update the block and helps avoid the overhead of
MAXTRANS
update a data block allocated to the table. This limit does not
apply to queries. This value can range from 1 to 255 and the
default is a function of the data block size. You should not change
the block until either the MAXTRANS value is exceeded or the block
TABLESPACE
omit this option, then ORACLE creates the table in the default
STORAGE
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 14/21
14/04/2018 Detailed ORACLE and SQL commands
CLUSTER
listed in this clause are the table columns that correspond to the
Specify one column from the table for each column in the cluster
clustered table uses the cluster's space allocation, do not use the
option.
ENABLE
DISABLE
enable and disable constraints with the ENABLE and DISABLE keywords
You cannot use the ENABLE and DISABLE clauses in a CREATE TABLE
AS subquery
inserts the rows returned by the subquery into the table upon its
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 15/21
14/04/2018 Detailed ORACLE and SQL commands
creation.
If you include this clause, the column definitions can only specify
columns of the selected table and the subquery does not modify the
omit the columns from the table definition entirely. In this case,
the names of the columns of table are the same as the columns in the
subquery.
PREREQUISITES:
To create a table in your own schema, you must have CREATE TABLE
must have CREATE ANY TABLE system privilege. Also, the owner of the
schema to contain the table must have either space quota on the
privilege.
SEE:
CONSTRAINT clause
PURPOSE:
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 16/21
14/04/2018 Detailed ORACLE and SQL commands
rule that restricts the values for one or more columns in a table.
SYNTAX:
Column constraint:
[CONSTRAINT constraint]
{ [NOT] NULL
| CHECK (condition) }
[TABLESPACE tablespace]
[STORAGE storage_clause] ]
| DISABLE }
Table constraint:
[CONSTRAINT constraint]
| CHECK (condition) }
[TABLESPACE tablespace]
[STORAGE storage_clause] ]
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 17/21
14/04/2018 Detailed ORACLE and SQL commands
| DISABLE }
where:
CONSTRAINT
stores this name in the data dictionary along with the definition of
SYS_Cn
where
data dictionary.
NULL
NOT NULL
is the default.
UNIQUE
PRIMARY KEY
key.
FOREIGN KEY
REFERENCES
ON DELETE CASCADE
CHECK
USING INDEX
or PRIMARY KEY constraint. The name of the index is the same as the
name of the constraint. You can choose the values of the INITRANS,
Only use this clause when enabling UNIQUE and PRIMARY KEY
constraints.
EXCEPTIONS INTO
before you use this option. If you omit schema, ORACLE assumes the
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 19/21
14/04/2018 Detailed ORACLE and SQL commands
DISABLE
integrity constraint.
You can also enable and disable integrity constraints with the
ENABLE and DISABLE clauses of the CREATE TABLE and ALTER TABLE
commands.
PREREQUISITES:
SEE:
Example: To define the table staff, as user scott, you could enter:
job CHAR(10),
PCTFREE 5 PCTUSED 75
http://clair.si.umich.edu/~radev/654/resources/oracledefs.html 21/21