ORACLE语句整理

表备份

1
2
3
4
-- 备份表结构和数据
create table table_name_new as select * from table_name_old where 1=1;
-- 备份空表结构
create table table_name_new as select * from table_name_old where 1=2;

查看当前用户下所有表

1
select table_name from user_tables;

查看当前用户下所有表及表注释

1
select * from user_tab_comments;

获取表字段:

1
select * from user_tab_columns where Table_Name='用户表' order by column_name

获取表注释:

1
select * from user_tab_comments where Table_Name='用户表' order by Table_Name

获取字段注释:

1
select * from user_col_comments where Table_Name='用户表' order by column_name