关于oracle(达梦)数据库的一些简单使用(根据表/列注释查询表名,删除表等等)

根据表注释查询表结构

select * FROM all_tab_comments t  where t.comments LIKE '%编号%';

根据表里面的列注释查询表结构

select * from  user_col_comments t;
select * from  user_col_comments t where comments like '%编号%';

为什么分开类似的数据我要查询两次呢?
是因为每张表的结构不一样,不是每张表的注释字段都是 comments,
你需要先查出自己表的注释字段是什么,然后再放进去第二个sql进行查询。

同理可得,是不是我们也可以用这个查字段之类的,其他值。。。可以试试。

删除表数据的两种方式

待条件删除deletedelete from users where userid='001';
不带条件删除deletedelete  table_name;
删除所有空间及索引:
Truncate table  table_name;
删除所有记录却保留占用空间:
Truncate table table_name  [reuse storage];

同理,删除表结构

删除之后不可回收:
drop table 表名 [purge]  purge表示不放入回收站
删除之后可回收,放入回收站,可从回收站拿回来:
drop table 表名 
查询回收站:
select * from recyclebin where type='TABLE';
删除回收站的表:
purge table tablename;
恢复回收站的表:
flashback table tablename to before drop;
删除回收站中所有表结构:
purge recyclebin;
删除所有表结构及索引:
truncate table 表名

猜你喜欢

转载自blog.csdn.net/hyfsbxg/article/details/128577426