oracle常用语句

create
tablespace chen1
datafile 'E:\app\chendabing\oradata\test\chen1.dbf'
size 100m
autoextend on next 50m maxsize 20480m
extent management local
/


创建表空间

ORA-01031:权限不足的问题
在 脚本更新时,报错:ORA-01031: 权限不足。
grant connect,resource,dba to cssy;
赋权DBA之后,还有这个错误。
执行 grant all privileges to cssy
赋予任何主机访问数据的权限,问题得到了解决。


--删除空的表空间,但是不包含物理文件
drop tablespace tablespace_name;
--删除非空表空间,但是不包含物理文件
drop tablespace tablespace_name including contents;
--删除空表空间,包含物理文件
drop tablespace tablespace_name including datafiles;
--删除非空表空间,包含物理文件
drop tablespace tablespace_name including contents and datafiles;
--如果其他表空间中的表有外键等约束关联到了本表空间中的表的字段,就要加上CASCADE CONSTRAINTS
drop tablespace tablespace_name including contents and datafiles CASCADE CONSTRAINTS;

sqlplus sys/oracle as sysdba; 登录DBA用户

 

创建表空间 create tablespace chen datafile 'F:\app\Administrator\oradata\luckChen\chen.dbf' size 100m autoextend on next 50m maxsize 20480m extent management local
/


1、查询表的数目:select count(*) from tabs
2、查询用户拥有哪些表:select * from tabs
3、SELECT * FROM ALL_TABLES WHERE OWNER='用户名'; ----要求是管理员用户
4.select table_name from user_tables; 查看当前用户所以的表常用


--删除空的表空间,但是不包含物理文件
drop tablespace tablespace_name;
--删除非空表空间,但是不包含物理文件
drop tablespace tablespace_name including contents;
--删除空表空间,包含物理文件
drop tablespace tablespace_name including datafiles;
--删除非空表空间,包含物理文件
drop tablespace tablespace_name including contents and datafiles;
--如果其他表空间中的表有外键等约束关联到了本表空间中的表的字段,就要加上CASCADE CONSTRAINTS
drop tablespace tablespace_name including contents and datafiles CASCADE CONSTRAINTS;

posted @ 2019-10-25 11:48  小生怕痒  阅读(170)  评论(0编辑  收藏  举报