1、删除表中的某一列
alter tableT_REQ_TEMPORARY_REQUIREMENTdropcolumnTEMPORARY_REQUIREMENT_TYPE_ID;
2、在表中增加一列
alter table T_REQ_TEMPORARY_REQUIREMENT add TEMPORARY_REQ_TYPE_ID varchar(32);
3、修改某一列的数据类型或者长度
alter table T_AA_VIEW_AREAalter columnCODEset data type VARCHAR(64);
4、创建一张表
5、创建序列
create sequence unify_todo_sequence
AS INT
START WITH 1
INCREMENT BY 1
MINVALUE 1
NO MAXVALUE
NO CYCLE
NO CACHE
ORDER;
6、批量新增数据
【insert into 表1(字段1,字段2) values(值1,值2)】(插入单条)
【insert into 表1 values(值1,值2)】(插入单条)
【insert into 表1(select * from 表2)】(批量插入)
【insert into 表1(字段)(select (相同数量类型的字段) from 表2)】(批量插入)
insert into T_AA_VIEW_AREA_TEST(ID,CODE,NAME)values('99','9999','test')
insert into T_AA_VIEW_AREA_TEST values('199','9999','test')
insert into T_AA_VIEW_AREA_TEST (select * from T_AA_VIEW_AREA)
insert into T_PTL_UNIFY_COMPLETED_TASK_BUSINESS_CODE_MAPPING (ID,PROCESS_DEFINITION_NAME,BUSINESS_CODE,UNIFY_COMPLETED_TASK_ID)
select NEXT VALUE FOR unify_completed_sequence,a.PROCESS_DEFINITION_NAME,a.BUSINESS_CODE,a.UNIFY_COMPLETED_TASK_IDfrom (表)a
7、批量修改数据
【update 表1 set 字段=值】(值为现有的数据)
【 update 表1 set(表1.字段1,表1.字段2)=
(select 表2.字段1,表2.字段2 from 表2 where 表2.ID=表1.ID)
where exists
( select 表2.字段1,表2.字段2 from 表2 where 表2.ID=表1.ID)
】(值为其他表的数据)
update T_AA_VIEW_AREA_TEST set CODE='0000'
update T_AA_VIEW_AREA_TEST a set(a.NAME,a.CODE)=
(
select b.NAME,b.CODE from T_AA_VIEW_AREA b where b.ID=a.ID
)
where exists
(
select b.NAME,b.CODE from T_AA_VIEW_AREA b where b.ID=a.ID
)
8、创建外键
alter table T_REQ_SYSTEM_REQUIREMENT_RESOURCE
add constraint F_REFERENCE_82 foreign key (TEMPORARY_REQUIREMENT_ID) references
T_REQ_TEMPORARY_REQUIREMENT (ID) on delete restrict on update restrict