■Object Types:
SQL> select object_type from dba_objects group by object_type;
CONSUMER GROUP
INDEX PARTITION
SEQUENCE
QUEUE
SCHEDULE
TABLE PARTITION
RULE
JAVA DATA
PROCEDURE
OPERATOR
LOB PARTITION
WINDOW
LOB
PACKAGE
PACKAGE BODY
LIBRARY
RULE SET
PROGRAM
TYPE BODY
CONTEXT
JAVA RESOURCE
XML SCHEMA
TRIGGER
JOB CLASS
UNDEFINED
DIRECTORY
TABLE
INDEX
SYNONYM
VIEW
FUNCTION
WINDOW GROUP
JAVA CLASS
INDEXTYPE
CLUSTER
TYPE
RESOURCE PLAN
EVALUATION CONTEXT
JOB
已选择39行。
■■■■Tables
■Naming Rules:
・ The name may be from 1 to 30 characters long (with the exception of database link names that may be up to 128 characters long).
・ Reserved words (such as SELECT) cannot be used as object names.
・ All names must begin with a letter from “A” through “Z.”
・ The characters in a name can only be letters, numbers, an underscore (_),the dollar sign ($), or the hash symbol (#).
・ Lowercase letters will be converted to uppercase.
■Object Namespaces
namespace A Name space defines agroup of object types,within which all names must be uniquely identified,by schema and name. Objecet in different namespace can share the same name.
These object types share the same namespace:
・Tables ・Views ・Sequences ・Private synomyms
Indexes and Constraints each have their own namespaces.
Thus it is possible for an index to have the same name as a table,even within the same schema;
■Create table
■Data Types
・alphanumeric data:
VARCHAR2,NVARCHAR2,CHAR
・binary data:
RAW(×),NUMBER,FLOAT,INTEGER
・date and time data:
DATE,TIMESTAMP,TIMESTAMP WITH TIMEZONE,TIMESTAMP WITH LOCAL TIMEZONE,INTERVAL YEAR TO MONTH,INTERVAL DAY TO SECOND
・large object data types:
CLOB,NCLOB,BLOB,BFILE,LONG(×),LONG RAW(×)
・ROWID data type:
ROWID
■Constraints
UNIQUE
NOT NULL
PRIMARY KEY
FOREIGN KEY
ON DELETE CASCADE;ON DELETE SET NULL
eg:
REFERENCES [ schema. ] { object_table | view }
[ (column [, column ]...) ]
[ON DELETE { CASCADE | SET NULL } ]
[ constraint_state ]
CHECK
・A primary key constraint is a unique constraint combined with a not null constraint.
・A foreign key constraint in a child table must reference the columns of either a unique constraint or a primary key constraint in the parent table.
■Alter table
Read-only tables:
alter table XXX READ ONLY;
alter table XXX READ WRITE;
■Drop table
・Moves a tables to the recycle bin
・Removes the table and all its data entirely if PURGE
syntax:
DROP TABLE [ schema. ]table
[ CASCADE CONSTRAINTS ]
[ PURGE ] ;
■Rename