oracle常用命令

1、分区关键字段不能更新
    alter table t_xj_hd enable row movement;
2、数据库解锁
   alter user srdh account unlock(SYS登陆)

3、增加分区
   alter table TDM_IN_CCR_TRMNL_PREFER_M add partition P201211 values (201211) tablespace TBS_DM

4、查询sql性能
   select * from v$sql
   
5、增加字段
   alter  table tab2 add col2 number(20)
   
5、修改字段属性
   alter  table tab2 modify col1 varchar2(20)
   
6、查询用户表空间
Select default_tablespace 默认表空间,temporary_tablespace  临时表空间 from dba_users Where username = 'SRDH_06'

7、启动数据库
   lsnrctl start
启动数据库
    sqlplus /nolog
    connect / as sysdba
--connect sys/longtop as sysdba
startup

8、关闭数据库
   lsnrctl stop
    sqlplus /nolog
    connect / as sysdba
    shutdown immediate
    
9、数据库解锁
  alter user username account unlock;
 
10、导出dmp文件命令
  Exp bicp/bicp@119 file=/home/oracle/masa_func.dmp tables=masa_func  (指定表)
  Exp bicp/bicp@119 file=/home/oracle/masa_func.dmp (导出用户下所有对象)

11、导入文件
  imp bicp/bicp@119 file=ghg.dmp log=ghg.log full=y ignore=y
 
12、查询一段时间之前的表数据
    select * from tab1 as of timestamp sysdate - interval '200' minute;
 
13、加主键
 alter table TAVBNAME add constraint 约束名 primary key (ID);
 
14、建同义词
 create or replace synonym 同义词名 for 用户名.表名;

15、加外键
alter table 表名
  add foreign key (字段)
  references 指向表 (指向表字段);

原文地址:https://www.cnblogs.com/zuo-zijing/p/3965608.html