`

oracle常用命令

 
阅读更多

1、导入导出

数据导出:
1 将数据库TEST完全导出,用户名system 密码manager 导出到D:\daochu.dmp中
exp system/manager@TEST file=d:\daochu.dmp full=y  compress=y 
2 将数据库中system用户与sys用户的表导出
exp system/manager@TEST file=d:\daochu.dmp owner=(system,sys)
3 将数据库中的表table1 、table2导出
exp system/manager@TEST file=d:\daochu.dmp tables=(table1,table2)
4 将数据库中的表table1中的字段filed1以"00"打头的数据导出
exp system/manager@TEST file=d:\daochu.dmp tables=(table1) query=\" where filed1 like '00%'\"
数据的导入
1 将D:\daochu.dmp 中的数据导入 TEST数据库中。
imp system/manager@TEST file=d:\daochu.dmp  ignore=y
2 将d:\daochu.dmp中的表table1 导入
imp system/manager@TEST file=d:\daochu.dmp tables=(table1) 

不同名之间的数据导入:

imp system/test@xe fromuser=hkb touser=hkb_new file=c:\orabackup\hkbfull.dmp 

赋予另一个用户表权限

1、grant all on tablename to A; //赋予用户A查询本用户表tablename的权限

grant create tablespace to A;

grant select on tabelname to A;

grant update on tablename to A;

grant execute on procedurename to A; 授权存储过程

grant select any table to robbie;       //该语句意思是将所有表的访问权限赋予给robbie.

4、拼语句

select 'trunct table' ||' '|| table_name||';'  from user_tables; 

5、检查4个时间是否重叠

(#{cbtime,jdbcType=DATE}, #{cetime,jdbcType=DATE}) overlaps (CBTIME,CETIME)

 

6、创建用户并授权

CREATE USER JOANDORA IDENTIFIED BY xxxxxx;

GRANT dba TO  JOANDORA;

2、查询

--查询表的主键约束名

select * from user_constraints e where e.table_name = 'T_CUST_CUSTOMERS'; --处输入表名

 

--查询所有引用到该主键的记录

select b.table_name, b.column_name

  from user_constraints a

 inner join user_cons_columns b

    on a.constraint_name = b.constraint_name

 where a.r_constraint_name = 'PK_T_CUST_CUSTOMERS'; --此处输入刚才查询出来的表主键的约束名

-- 查询表的索引

select t.*, i.index_type

  from user_ind_columns t, user_indexes i

 where t.index_name = i.index_name

   and t.table_name = i.table_name

   and t.table_name = 'T_CUST_CUSTOMERS';

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics