SQLÓï¾äPART5
Confirming granted privileges
Data Dictionary View Description
ROLE_SYS_PRIVS System privileges granted to roles
ROLE_TAB_PRIVS Table privileges granted to roles
USER_ROLE_PRIVS Roles accessible by the user
USER_SYS_PRIVS System privileges granted to the user
USER_TAB_PRIVS_MADE Object privileges granted on the user's objects
USER_TAB_PRIVS_RECD Object privileges granted to the user
USER_ROLE_PRIVS_MADE Object privileges granted on the columns of the user's objects
USER_ROLE_PRIVS_RECD: Object privileges granted to the user on specific columns
Revoking Object Privileges
grammer:
revoke {privileges [, privileges...] | all}
on object from {user [,...user...] | role | pubic} cascade constraints;
// privileges granted to others through the WITH GRANT OPTION clause are also revoked.
Alter table statement
grammer:
alter table table1 add (column datatype [default expr] [, column datatype]...);
alter table table1 modify (column datatype [default expr] [, column datatype]...);
alter table table1 drop (column);
Alter table (set unused option)
grammer:
alter table <table_name> set unsed (<column_name>);
or
alter table <table_name> set unsed column <column_name>;
then:
alter table <table_name> drop unused columns;
Constraint: Adding a constraint Syntax
grammer:
alter table <table_name> add [constraint <constraint_name>] type (<column_name>);
e.g.:
alter table emp2 modify employee_id primary key;
alter table emp2 add constraint emp_mgr_fk foreign key(manager_id) references emp2(employee_id);
Ïà¹ØÎĵµ£º
ΪÁË´¦Àí SQL Óï¾ä£¬ORACLE ±ØÐë·ÖÅäһƬ½ÐÉÏÏÂÎÄ( context area )µÄÇøÓòÀ´´¦ÀíËù±ØÐèµÄÐÅÏ¢£¬ÆäÖаüÀ¨Òª´¦ÀíµÄÐеÄÊýÄ¿£¬Ò»¸öÖ¸ÏòÓï¾ä±»·ÖÎöÒÔºóµÄ±íʾÐÎʽµÄÖ¸ÕëÒÔ¼°²éѯµÄ»î¶¯¼¯(active set)¡£
ÓαêÊÇÒ»¸öÖ¸ÏòÉÏÏÂÎĵľä±ú( handle)»òÖ¸Õ롣ͨ¹ýÓα꣬PL/SQL¿ÉÒÔ¿ØÖÆÉÏÏÂÎÄÇøºÍ´¦ÀíÓï¾äʱÉÏÏÂÎÄÇø»á·¢ÉúÐ ......
SQLÓï¾äÓï·¨
Ŀ¼
13.1. Êý¾Ý¶¨ÒåÓï¾ä
13.1.1. ALTER DATABASEÓï·¨
13.1.2. ALTER TABLEÓï·¨
13.1.3. CREATE DATABASEÓï·¨
13.1.4. CREATE INDEXÓï·¨
13.1.5. CREATE TABLEÓï·¨
13.1.6. DROP DATABASEÓï·¨
13.1.7. DROP INDEXÓï·¨
13.1.8. DROP TABLEÓï·¨
13.1.9. RENAME TABLEÓï·¨
13.2. Êý¾Ý²Ù×÷Óï¾ ......
µÚʮһÌ⣺
Óбístudents(name,class,grade),ÇëÓñê×¼sqlÓï¾äÍê³É
name class grade
ÕÅÈý Êýѧ 81
ÀîËÄ ÓïÎÄ 70
ÍõÎå Êýѧ 90
ÕÅÈý ÓïÎÄ 60
ÀîËÄ Êýѧ 100
ÍõÎå ÓïÎÄ 90
ÍõÎå Ó¢Óï 81
ÒªÇó: ÓÃsqlÓï¾äÊä³ö¸÷ÃŹ¦¿Î¶¼´óÓÚ80·ÖµÄͬѧÐÕÃû?
create table students (
name varchar(25),
class varchar(25),
grad ......
1¡¢¶ÔÏóÀàÐ͹淶
´´½¨¶ÔÏóÀàÐ͹淶µÄÓï·¨ÈçÏÂ
CREATE [OR REPLACE] TYPE [schema.] type_name
[AUTHID {CURRENT_USER|DEFINER}] AS OBJECT (
Attribute1 datatype,
[attribute2 datatype,…]
[method 1]
[method 2]);
/
ÆäÖÐAUTHIDָʾ½«À´Ö´Ðи÷½·¨Ê±£¬ ......
constraint Example:
1. grammer:
create table [schema.]table
(column datatype [DEFAULT expr]
[column_constraint], ...
[table_constraint] [,......]);
2. example of a column_level constraint:
create table empl ......