1 更改表的列名
SQL> alter table risenet_jxfgw.risenet_employee
2 rename column employee_mobile
3 to employee_tel;
表已更改。
2 删除表的列
SQL> alter table risenet_jxfgw.risenet_employee
2 drop column employee_isdeleted;
表已更改。
删除列是DDL语句,不可以回滚。
3 数据很多时,需要删除列,可以删除一部分提交一下
SQL> alter table risenet_jxfgw.test
2 drop column employee_photo
3 cascade constraints checkpoint 20;
表已更改。
4 数据库很忙,又要删除一列,则可以把该列设成“无用”,等数据库不忙再删除
SQL> l
1 alter table risenet_jxfgw.test
2* set unused column EMPLOYEE_ISDELETEDDESC cascade constraints
SQL> /
表已更改。
5 删除表所有数据
SQL> truncate table risenet_jxfgw.test;
表被截断。
truncate是DDL语句,所以不能回滚,而delete是DML语句,可以回滚。
****************************************
1 查询用户的状态,创建时间
SQL> select username,account_status,created from dba_users;
USERNAME ACCOUNT_STATUS CREATED
------------------------------ -------------------------------- --------------
MGMT_VIEW OPEN 30-8月 -05
SYS OPEN 30-8月 -05
SYSTEM OPEN 30-8月 -05
DBSNMP OPEN 30-8月 -05
SYSMAN OPEN 30-8月 -05
RISENET_JXFGW OPEN 21-3月 -08
OUTLN EXPIRED & LOCKED 30-8月 -05
MDSYS EXPIRED & LOCKED 30-8月 -05
ORDSYS EXPIRED & LOCKED 30-8月 -05
CTXSYS EXPIRED & LOCKED 30-8月 -05
ANONYMOUS EXPIRED & LOCKED 30-8月 -05
2 创建用户
SQL> create user dog
2 identified by wangwang
3 default tablespace risenet
4 temporary tablespace temp
5 quota 10M on risenet
6 quota 10M on users
7 password expire; //登陆之后需要该密码
用户已创建。
3 用户的所在表空间
SQL> l
1 select username,default_tablespace,temporary_tablespace
2* ,created from dba_users where username='DOG'
SQL> /
USERNAME DEFAULT_TABLESPACE
------------------------------ ------------------------------
TEMPORARY_TABLESPACE CREATED
------------------------------ --------------
DOG RISENET
TEMP 28-3月 -08
4 查该用户的表空间的配额
SQL> select username,tablespace_name,bytes/1024/1024 "MB",
2 max_bytes/1024/1024 "Max MB"
3 from dba_ts_quotas
4 where username='DOG';
USERNAME TABLESPACE_NAME MB
------------------------------ ------------------------------ ----------
Max MB
----------
DOG USERS 0
10
DOG RISENET 0
10
5 改变用户的表空间配额
SQL> alter user dog
2 quota 5M on users;
用户已更改。
SQL> select username,tablespace_name,bytes/1024/1024 "MB",
2 max_bytes/1024/1024 "Max MB"
3 from dba_ts_quotas
4 where username='DOG';
USERNAME TABLESPACE_NAME MB
------------------------------ ------------------------------ ----------
Max MB
----------
DOG USERS 0
5
DOG RISENET 0
10
6 SQL> drop user dog;
用户已删除。
SQL> select * from dba_users
2 where username='DOG';
未选定行
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12778571/viewspace-255328/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/12778571/viewspace-255328/