公司dba提供的脚本: set serveroutput on set feedback off spool /tmp/getcomments.out select 'comment on table ' || table_name || ' is ' || '''' || comments || ''';' from user_tab_comments where comments is not null; select 'comment on column ' || table_name |…
SQL语句获取数据库中的表主键,自增列,所有列 获取表主键 1:SELECT TABLE_NAME,COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGEWHERE TABLE_NAME<>'dtproperties' 2:EXEC sp_pkeys @table_name='表名' 3: select o.name as 表名,c.name as 字段名,k.colid as 字段序号,k.keyno as 索引顺序,t.name as…
1.Oracle查询数据库中所有表的记录数,但是有可能不准建议用第二种方式进行查询 select t.table_name,t.num_rows from user_tables t 2.创建oracle函数,通过函数中查询词表记录数显示当前记录数 create or replace function count_rows(table_name in varchar2, owner in varchar2 default null) return number authid current_us…
SELECT (case when a.colorder=1 then d.name else null end) 表名, a.colorder 字段序号,a.name 字段名, (case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end) 标识, (case when (SELECT count(*) FROM sysobjects WHERE (name in (SELECT name FROM…
查询用户创建的表 select * from user_tab_comments; -- 查询本用户的表,视图等. select * from user_col_comments; -- 查询本用户的表的列名和注释. 查询所有表大小 select Segment_Name, Sum(bytes) / 1024 / 1024 / 1024 "size(DB)" From User_Extents Group By Segment_Name order by "size(DB)&…