日期:2014-05-17 浏览次数:21126 次
--第一步:创建表,及相应的主键约束pk_test_id SQL> create table test(id number constraint pk_test_id primary key); Table created. --第二步:此时总共有9个约束 SQL> select constraint_name from user_constraints; CONSTRAINT_NAME ------------------------------ BIN$vL7ij8sVLTjgQAB/AQAPeg==$0 PK_TEST_ID BIN$vL7ij8sYLTjgQAB/AQAPeg==$0 BIN$uvy0dxvyoYvgQAB/AQAMpQ==$0 BIN$uvy0dxwAoYvgQAB/AQAMpQ==$0 BIN$uvy0dxvsoYvgQAB/AQAMpQ==$0 BIN$uvy0dxvvoYvgQAB/AQAMpQ==$0 BIN$uvy0dxv6oYvgQAB/AQAMpQ==$0 BIN$uvy0dxv9oYvgQAB/AQAMpQ==$0 9 rows selected. --第三步:删除表,按理说相应的约束应该被干掉了 SQL> drop table test; Table dropped. --第四步:此时还有9个约束,只是把约束的名称改了下,难道相应的约束没被干掉? SQL> select constraint_name from user_constraints; CONSTRAINT_NAME ------------------------------ BIN$vL7ij8sVLTjgQAB/AQAPeg==$0 BIN$vL7ij8sYLTjgQAB/AQAPeg==$0 BIN$vL7ij8sbLTjgQAB/AQAPeg==$0 BIN$uvy0dxvyoYvgQAB/AQAMpQ==$0 BIN$uvy0dxwAoYvgQAB/AQAMpQ==$0 BIN$uvy0dxvsoYvgQAB/AQAMpQ==$0 BIN$uvy0dxvvoYvgQAB/AQAMpQ==$0 BIN$uvy0dxv6oYvgQAB/AQAMpQ==$0 BIN$uvy0dxv9oYvgQAB/AQAMpQ==$0 9 rows selected.
SQL> create table test(id number constraint pk_test_id primary key); Table created SQL> select table_name from user_tables; TABLE_NAME ------------------------------ TEST SQL> select table_name,constraint_name from user_constraints; TABLE_NAME CONSTRAINT_NAME ------------------------------ ------------------------------ TEST PK_TEST_ID SQL> drop table test; Table dropped SQL> select table_name from user_tables; --BIN$VnncqINTRy+7ruGTE76IlQ==$0为删除后的表名 TABLE_NAME ------------------------------ BIN$VnncqINTRy+7ruGTE76IlQ==$0 SQL> select table_name,constraint_name from user_constraints; --table_name跟user_table的表名相同,可以关联上 TABLE_NAME CONSTRAINT_NAME ------------------------------ ------------------------------ BIN$VnncqINTRy+7ruGTE76IlQ==$0 BIN$nIZCU2gMRrujmIOafsDtBg==$0 SQL> flashback recyclebin; --清空回收站 Done SQL> select table_name from user_tables; TABLE_NAME ------------------------------ SQL> select table_name,constraint_name from user_constraints; TABLE_NAME CONSTRAINT_NAME ------------------------------ ------------------------------