五、查询实例?所有库名?表名? select * from v$database; show parameter db; // 查看当前的所有数据库:
show parameter optimizer; //显示设置信息
select table_name from user_tables; //当前用户的表
select table_name from all_tables; //所有用户的表
select table_name from dba_tables; //包括系统表
看字段名与数据类型:
desc talbename;
查看主键:
select * from user_constraints where constraint_type=\'P\' and TABLE_name=upper(\'TRD_USER\')
查看表空间的sql语句
col tablespace_name format a10;
select f.tablespace_name,a.total,u.used,f.free,round((u.used/a.total)*100) \"% used\",
round((f.free/a.total)*100) \"% Free\"
from
(select tablespace_name, sum(bytes/(1024*1024)) total
from dba_data_files group by tablespace_name) a,
(select tablespace_name, round(sum(bytes/(1024*1024))) used
from dba_extents group by tablespace_name) u,
(select tablespace_name, round(sum(bytes/(1024*1024))) free
from dba_free_space group by tablespace_name) f
WHERE a.tablespace_name = f.tablespace_name
and a.tablespace_name = u.tablespace_name;