最近要查询一些数据库的基本情况,由于以前用oracle数据库比较多,现在换了MySQL数据库,就整理了一部分语句记录下来. 1.查询数据库表数量 #查询MySQL服务中数据库表数据量 SELECT COUNT(*) TABLES, table_schema FROM information_schema.TABLES GROUP BY table_schema; #查询指定数据库表数量 SELECT COUNT(*) TABLES, table_schema FROM information_s
查询指定表结构的表名.列名.类型.说明.字段长度 select o.name as tableName,c.name as columnName,t.name as columnType,p.value as columnDescription,c.prec from sysobjects o left join syscolumns c on o.id=c.idleft join sys.extended_properties p on p.major_id=c.id and p.mino
--查询sql 查询表列名Select Name FROM SysColumns Where id=Object_Id('Tab') --查询sql数据库表列名称select name from syscolumns where id=(select max(id) from sysobjects where xtype='u' and name='Tab') --查询oracle数据库表列名称select * from user_tab_cols where table_name = 'Tab
1.查询数据库中的所有数据库名: SELECT Name FROM Master..SysDatabases ORDER BY Name 2.查询某个数据库中所有的表名: SELECT Name FROM SysObjects Where XType='U' ORDER BY Name ==表中字段 1.方法一 SELECT * FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='表名' 2.方法二 select a.name tablename,
意:本篇文章仅适用于mysql和postgre这两种数据库 1.查询数据库中所有表名及对应表的详细信息 select * from INFORMATION_SCHEMA.tables 2.根据指定名称查询表名(也可模糊查询,可查询表的详细信息) select * from INFORMATION_SCHEMA.tables where table_name = 'eguid'; select * from INFORMATION_SCHEMA.tables where table_name l
在编写程序时,总是有些变量的类型搞不很明白,现将目前涉及到的变量总结一下: 1.“时间”类型 (1).在数据库中的变量类型是:DateTime 比如: operateTime DATETIME,//数据库中编写的字段类型 (2).在java程序中的变量类型是:Date 比如: private Date operatetime;// 操作时间 //set.get方法 public Date getOperatetime() { return operatetime; } public void s
一.查询所有数据库占用空间大小 SELECT TABLE_SCHEMA, CONCAT( TRUNCATE(SUM(data_length) / 1024 / 1024, 2), ' MB' ) AS data_size, CONCAT( TRUNCATE(SUM(index_length) / 1024 / 1024, 2), 'MB' ) AS index_size FROM information_schema.tables GROUP BY TABLE_SCHEMA ORDER BY d
获取指定表列名及备注: select * from syscolumns where id=object_id(N'表名') SELECT a.name [column], b.name type, a.prec length, isnull(c.value, ' ') [description] FROM syscolumns a LEFT OUTER JOIN systypes b ON a.xusertype = b.xusertype LEFT OUTER JOIN sys.extend
查询数据库的占用 SELECT CONCAT(ROUND(SUM(index_length)/(1024*1024), 2), ' MB') AS 'Total Index Size' , CONCAT(ROUND(SUM(data_length)/(1024*1024), 2), ' MB') AS 'Total Data Size' FROM information_schema.TABLES where table_schema like 'edb_a%' ; 查询表的占用 SELECT