Oracle数据库

1.修改主键数据类型

ALTER TABLE FRMMANAGETABLE ADD NEW_OBJECT_ID VARCHAR2(32);
UPDATE FRMMANAGETABLE SET NEW_OBJECT_ID = TABLEID;
ALTER TABLE FRMMANAGETABLE DROP COLUMN TABLEID;
ALTER TABLE FRMMANAGETABLE RENAME COLUMN NEW_OBJECT_ID TO TABLEID;

-----将主键从其他类型转换成为VARCHAR2(32)

2.查找出所有CLOSE外键约束的语句

SELECT   'alter table '||TABLE_NAME ||' disable constraint '||CONSTRAINT_NAME||';'  FROM   USER_CONSTRAINTS   WHERE   (CONSTRAINT_TYPE= 'R' or CONSTRAINT_TYPE='P') and owner = 'NEWJW2010' and TABLE_NAME not like 'BIN%' ;

3.查找出恢复外键的语句

SELECT   'alter table '||TABLE_NAME ||' enable constraint '||CONSTRAINT_NAME||';'   FROM   USER_CONSTRAINTS   WHERE   (CONSTRAINT_TYPE= 'R' or CONSTRAINT_TYPE='P')  and owner = 'NEWJW2010' and TABLE_NAME not like 'BIN%' ;



你可能感兴趣的:(oracle,数据库,object,user,table,constraints)