SELECT TABLE_NAME, -- 表名 COLUMN_NAME, -- 字段名 DATA_TYPE, -- 字段类型 COLUMN_COMMENT -- 字段注释 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '数据库名称'…
查询数据库中所有表名select table_name from information_schema.tables where table_schema='csdb' and table_type='base table'; 查询指定数据库中指定表的所有字段名column_nameselect column_name from information_schema.columns where table_schema='csdb' and table_name='users'…
查询数据库中所有表名select table_name from information_schema.tables where table_schema='数据库名' and table_type='base table';查询指定数据库中指定表的所有字段名column_nameselect column_name from information_schema.columns where table_schema='数据库名' and table_name='表名'; #查看分布式系统中不同…
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…
用SQL语句创建和删除Access数据库中的表;添加列和删除列 Posted on 2009-08-11 13:42 yunbo 阅读(1240) 评论(0) 编辑 收藏 用SQL语句创建和删除Access数据库中的表;添加列和删除列SQL语句,具体使用方法请看帮助          Create    Table    tab1    (fld1    integer)      Drop    Table    tab1          Alter    Table    tab1   …
想知道数据库中哪表含有edu_status字段   mysql> select table_name,column_name from information_schema.columns where column_name like '%edu_status%'; +-------------+-------------------+ | table_name  | column_name       | +-------------+-------------------+ | mytest…
查看所有mysql数据库表和索引大小 mysql查看当前所有的数据库和索引大小 ,),' mb') as data_size, concat(,),'mb') as index_size from information_schema.tables group by table_schema order by data_length desc; mysql查看当前某个数据库和数据库下所有的表的大小 ,),' mb') as data_size, concat(,),' mb') as index…
Oracle: SELECT * FROM ALL_TABLES;系统里有权限的表 SELECT * FROM DBA_TABLES; 系统表 SELECT * FROM USER_TABLES; 当前用户下的表     Sql Server 1,利用sysobjects系统表 在这个表中,在数据库中创建的每个对象(例如约束.默认值.日志.规则以及存储过程)都有对应一行,我们在该表中筛选出xtype等于U的所有记录,就为数据库中的表了. 示例语句如下:: select * from sysobj…
原文地址:http://blog.csdn.net/pukuimin1226/article/details/7687538 ----查询数据库中用户创建的表 ----jsj01 为数据库名 select name tablename from jsj01..sysobjects where type='U' and name not in ('dtproperties') --查询表里的字段信息 exec sp_help 对象名 ---docs为表名 select * from syscolu…
查询数据库里所有表名和字段名的语句SQL 查询所有表名:SELECT NAME FROM SYSOBJECTS WHERE TYPE='U'SELECT * FROM INFORMATION_SCHEMA.TABLES查询表的所有字段名:SELECT NAME FROM SYSCOLUMNS WHERE ID=OBJECT_ID(' 表名' )SELECT * FROM INFORMATION_SCHEMA.TABLESSELECT * FROM INFORMATION_SCHEMA.VIEWS…
SELECT TABLE_NAME '表名',TABLE_SCHEMA '数据库名',ORDINAL_POSITION '顺序',COLUMN_NAME '字段',DATA_TYPE '类型' ,CHARACTER_OCTET_LENGTH '字节长',IF(COLUMN_KEY='PRI',"√","") '主键',IF(EXTRA='auto_increment',"√","") '自增长' ,IF(IS_NULLABLE…
每个mysql都有一个库information_schema,里面有一张表TABLES存储了所有数据库表的信息,因此,可以从这张表中查看数据库大小和表大小 查询数据库大小 ,),'GB') as data from information_schema.tables where table_schema='esb'; 查询数据库中表大小 ,),'GB') as data from information_schema.tables where table_schema='esb' and tab…
use information_schema; SELECT DISTINCT t.table_name, t.engine '表引擎', t.table_rowsFROM TABLES tWHERE 1 = 1AND t.table_schema = 'mysql_database_name'-- 自己数据库的名字 AND t. ENGINE IS NOT NULLORDER BY t.table_name,t.table_rows ; SELECTt.TABLE_SCHEMA '数据库',t…
select table_name,table_rows from information_schema.tables where TABLE_SCHEMA = '数据库名称' order by table_rows desc;…
SELECT TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS,concat(round((DATA_LENGTH+INDEX_LENGTH)//,), 'MB') as data FROM information_schema.tables WHERE TABLE_SCHEMA='test' ORDER BY DATA_LENGTH+INDEX_LENGTH desc; 结果展示:…
1. 查询单表 EXEC sp_spaceused 'dbo.tablename' 2. 查询所有表 SELECT t.NAME AS TableName, s.Name AS SchemaName, p.rows AS RowCounts, AS TotalSpaceKB, AS UsedSpaceKB, ( AS UnusedSpaceKB FROM sys.tables t INNER JOIN sys.indexes i ON t.OBJECT_ID = i.object_id INNE…
For example: exec sp_MSForEachTable @precommand=N'create table temp(name sysname,rows bigint,reserved Nvarchar(100),data varchar(100),index_size varchar(100),unused varchar(100))',@command1=N'insert temp exec sp_spaceused ''?''',@postcommand=N'select…
select TABLE_NAME, concat(truncate(data_length/1024/1024,2),'MB') as data_size, concat(truncate(index_length/1024/1024,2),'MB') as index_size from information_schema.tables where TABLE_SCHEMA = '数据库名称' group by TABLE_NAME order by data_length desc;…
select a.name,b.rows from sysobjects a,sysindexes b where a.name = b.name order by b.rows desc…
SELECT TableName = obj.name, TotalRows = prt.rows, [SpaceUsed(KB)] = SUM(alloc.used_pages)* FROM sys.objects obj JOIN sys.indexes idx on obj.object_id = idx.object_id JOIN sys.partitions prt on obj.object_id = prt.object_id JOIN sys.allocation_units…
方法一: SELECT a.name,b.rows FROM sysobjects a INNER JOIN sysindexes b ON a.id=b.id ,) AND a.Type='u' ORDER BY b.rows desc 方法二: ), RowCnt INT) EXEC sp_MSforeachtable 'INSERT INTO #temp SELECT ''?'', COUNT(*) FROM ?' select * from #temp order by RowCnt d…
select t.table_name,t.num_rows from user_tables t…
use information_schema; select table_name,table_rows from tables where TABLE_SCHEMA = 'testdb'  order by table_rows desc;…
select b.name,a.colid,a.name ,())+')' from systypes where a.xusertype=systypes.xusertype ) type fromsyscolumns a left outer join sysobjects b on a.id=b.id where b.xtype='U'and b.name = 'hq_hotel' order by b.name,a.colid…
select table_name from information_schema.columns where table_schema = '库名' and column_name='字段名';  …
其实本来只想找一个方法能查询一下 数据库 的大小,没想到这个方法还能查询数据库中 各个数据表 的大小,嗯,挺好玩的,记录一下. MSDN资料:https://msdn.microsoft.com/zh-cn/library/ms188776.aspx 如果只是查询数据库的大小的话,直接使用以下语句即可: EXEC sp_spaceused 为了保证查询结果的实时性,推荐使用 @updateusage 参数来确保统计数据是最新的: EXEC sp_spaceused @updateusage =…
查询数据库中所有表名 select table_name from information_schema.tables where table_schema='csdb' and table_type='base table'; 查询指定数据库中指定表的所有字段名 select column_name from information_schema.columns where table_schema='csdb' and table_name='users';…
1,根据数据库类型拼接不同URL /** * 根据类型不同拼接连接的URL * @param dbType 1:mysql.2:oracle.3:sql server.4:gp * @param ip * @param port * @param databaseName * @return*/ public static String getTestDbUrl(int dbType, String ip, String port, String databaseName){ String ur…
转载:https://www.cnblogs.com/diandiandidi/p/5582309.html 1.要查询表所占的容量,就是把表的数据和索引加起来就可以了 select sum(DATA_LENGTH)+sum(INDEX_LENGTH) from information_schema.tables where table_schema='数据库名'; 上面获取的结果是以字节为单位的,可以通过%1024在%1024的到M为单位的结果. 2.查询所有的数据大小 select conc…
1.查询sjcenter数据库里开头为sj_demo和sj_onlyinv的所有表的总条数 select sum(table_rows) from (select table_name,table_rows from tables  where TABLE_SCHEMA = 'sjcenter'  order by table_rows desc) as b where b.table_name like 'sj_demo%' or b.table_name like 'sj_onlyinv'…