加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-12 15:15:31 所属栏目:百科 来源:网络整理
导读:oracle基本操作,Oracle修改列名,Oracle修改字段类型 ?Copyright蕃薯耀 2017年3月16日 http://fanshuyao.iteye.com/ --修改列名alter table "KFAPP"."H_USERS" rename column "STATUS" to "new_column"--新增列alter table h_usersadd (column_name nvarcha

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

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

?Copyright蕃薯耀 2017年3月16日

http://fanshuyao.iteye.com/

--修改列名
alter table "KFAPP"."H_USERS" rename column "STATUS" to "new_column"

--新增列
alter table h_users
add (column_name nvarchar2(1) default '1' not null);
eg:
alter table h_users
add (delete_type nvarchar2(1) default '1' not null);


--删除列
1、alter table h_users drop column my_type;
2、alter table table_name drop (column_name);
eg:
alter table h_users drop (deleteType);
alter table "H_USERS" drop column "DELETE_TYPE" 

--修改列类型
alter table tablename modify 
(column_name colomn_type [default value][null/not null]);
eg:
alter table h_users modify 
(my_type int default 1);

-- 查询锁表情况
select s.SID,s.SERIAL# from v$locked_object a,dba_objects b,v$session s
where a.OBJECT_ID=b.OBJECT_ID and a.SESSION_ID=s.SID
   
-- 干掉锁表进程
alter system kill session '852,28988';

-- 表H_USERS,自增长字段USER_ID 
-- 创建序列
create sequence H_USERS_ID_SEQ
start with 1
increment by 1
nomaxvalue
minvalue 1
nocycle
cache 10;

-- 创建触发器
create trigger H_USERS_ID_TRG  
     before insert on H_USERS for each row  
 begin  
     select H_USERS_ID_SEQ.nextval into:new.USER_ID from dual;
 end; 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

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

?Copyright蕃薯耀 2017年3月16日

http://fanshuyao.iteye.com/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读