Oracle 不常用sql

1.查看当前数据库表格

select t.* from tabs t 

select t.* from user_tables t

2.查看指定表格定义语句(TABLE、VIEW、INDEX)

SELECT DBMS_METADATA.GET_DDL('TABLE','表名') FROM DUAL

3.查看表索引

 select * from user_indexes

4.查看列信息

 select * from user_tab_columns

5.查看表格备注

 select *  from user_tab_comments   

6.查看列备注

select *   from user_col_comments   

7.查看慢查询

SELECT
	* 
FROM
	(
SELECT
	sa.SQL_TEXT,
	sa.SQL_FULLTEXT,
	sa.EXECUTIONS "执行次数",
	round( sa.ELAPSED_TIME / 1000000, 2 ) "总执行时间",
	round( sa.ELAPSED_TIME / 1000000 / sa.EXECUTIONS, 2 ) "平均执行时间",
	sa.COMMAND_TYPE,
	sa.PARSING_USER_ID "用户ID",
	u.username "用户名",
	sa.HASH_VALUE 
FROM
	v$sqlarea sa
	LEFT JOIN all_users u ON sa.PARSING_USER_ID = u.user_id 
WHERE
	sa.EXECUTIONS > 0  and u.username='GZMPCYSJF'
ORDER BY
	( sa.ELAPSED_TIME / sa.EXECUTIONS ) DESC 
	) 
WHERE
	ROWNUM <= 100;

 

你可能感兴趣的:(oracle)