天天看点

Oracle基本操作,Oracle修改列名,Oracle修改字段类型

oracle基本操作,Oracle修改列名,Oracle修改字段类型

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

©Copyright 蕃薯耀 2017年3月16日

http://www.cnblogs.com/fanshuyao/

Sql代码  

Oracle基本操作,Oracle修改列名,Oracle修改字段类型

  1. --修改列名  
  2. alter table "KFAPP"."H_USERS" rename column "STATUS" to "new_column"  
  3. --新增列  
  4. alter table h_users  
  5. add (column_name nvarchar2(1) default '1' not null);  
  6. eg:  
  7. add (delete_type nvarchar2(1) default '1' not null);  
  8. --删除列  
  9. 1、alter table h_users drop column my_type;  
  10. 2、alter table table_name drop (column_name);  
  11. alter table h_users drop (deleteType);  
  12. alter table "H_USERS" drop column "DELETE_TYPE"   
  13. --修改列类型  
  14. alter table tablename modify   
  15. (column_name colomn_type [default value][null/not null]);  
  16. alter table h_users modify   
  17. (my_type int default 1);  
  18. -- 查询锁表情况  
  19. select s.SID,s.SERIAL# from v$locked_object a ,dba_objects b ,v$session s  
  20. where a.OBJECT_ID=b.OBJECT_ID and a.SESSION_ID=s.SID  
  21. -- 干掉锁表进程  
  22. alter system kill session '852,28988';  
  23. -- 表H_USERS,自增长字段USER_ID   
  24. -- 创建序列  
  25. create sequence H_USERS_ID_SEQ  
  26. start with 1  
  27. increment by 1  
  28. nomaxvalue  
  29. minvalue 1  
  30. nocycle  
  31. cache 10;  
  32. -- 创建触发器  
  33. create trigger H_USERS_ID_TRG    
  34.      before insert on H_USERS for each row    
  35.  begin    
  36.      select H_USERS_ID_SEQ.nextval into:new.USER_ID from dual;  
  37.  end;   

今天越懒,明天要做的事越多。

继续阅读