1、oracle在navicat常用sql语句
oracle在navicat中有很多常用的sql语句,表示当前用户的表、系统表、用户表、获取表注释等常用sql方法。
select table_name from user_tables; //当前用户的表
select table_name from all_tables; //所有用户的表
select table_name from dba_tables; //包括系统表
select table_name from dba_tables where owner='用户名'
select * from user_tab_comments where TABLE_NAME = 'T_CJ_ENTRUST_INFO';//查询表及表注释
select * from user_tab_columns where Table_Name='用户表';
select * from user_tab_columns where Table_Name='用户表';
select * from all_tab_columns where Table_Name='用户表';
select * from dba_tab_columns where Table_Name='用户表';
select * from user_tab_comments //获取表注释
--user_tab_comments:table_name,table_type,comments
select * from user_col_comments //获取字段注释
--user_col_comments:table_name,column_name,comments
SELECT t.table_name, t.num_rows FROM user_tables t WHERE NUM_ROWS IS NOT NULL AND TABLE_NAME NOT LIKE '%HIS%' ORDER BY NUM_ROWS DESC; //查看表对应的数据量,直接复制、粘贴进行查询
2、oracle在navicat中获取表注释的2种方法
oracle在navicat中获取表注释的2种方法,可以根据方案一 和方案二去查询。
###方案1
SELECT
t.column_id,
t.TABLE_NAME ,
t.COLUMN_NAME ,
c.COMMENTS ,
t.DATA_TYPE ,
t.DATA_LENGTH ,
t.NULLABLE
FROM
all_tab_columns t
INNER JOIN all_col_comments c ON
t.TABLE_NAME = c.TABLE_NAME
AND t.COLUMN_NAME = c.COLUMN_NAME
WHERE
t.Table_Name = '修改为你需要查看表注释内容的表名,其他所有代码复制、粘贴'
ORDER BY
t.column_id ;
###方案2
SELECT
t.COLUMN_ID,
t.COLUMN_NAME,
u.COMMENTS,
t.DATA_TYPE ,
t.DATA_LENGTH ,
DECODE( t.NULLABLE, 'N', 'TRUE', 'FALSE'),
t.TABLE_NAME
FROM
USER_TAB_COLUMNS t
LEFT JOIN USER_COL_COMMENTS u ON
t.TABLE_NAME = u.TABLE_NAME
AND t.COLUMN_NAME = u.COLUMN_NAME
WHERE
t.TABLE_NAME = '修改为你需要查看表注释内容的表名,其他所有代码复制、粘贴'
ORDER BY
t.COLUMN_ID ASC;
例子举例显示:
![](https://img.haomeiwen.com/i26045017/21d64fc0bd83f9df.png)
网友评论