zoukankan      html  css  js  c++  java
  • Oracle基本操作,Oracle修改列名,Oracle修改字段类型

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

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

    ©Copyright 蕃薯耀 2017年3月16日

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

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

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

    ©Copyright 蕃薯耀 2017年3月16日

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

  • 相关阅读:
    [算法初步]希尔排序
    逆波兰表达式1(简介)
    [数据结构]之链表
    [数据结构]之栈
    [算法初步]之归并排序
    [算法初步]之快速排序
    [算法初步]之冒泡排序
    逆波兰表达式2中缀转后缀表达式)
    [算法初步]之简单选择排序
    [数据结构]之顺序表
  • 原文地址:https://www.cnblogs.com/fanshuyao/p/6558488.html
Copyright © 2011-2022 走看看