如果一个数据库中表的数量较多的话,那么在统计数据库中表的数量或视图或存储过程的数量时,如果还有一个一个去数,那就太麻烦了,其实可以通过 sql 语句来查询的,sql 语句的查询方法如下: sql server : select count(1) from sysobjects where xtype='U' 数据表 select count(1) from sysobjects where xtype='V' 视图 select count(1) from sysobjects where xt…
1. 查看用户表 select name from sys.tables select name from sys.objects where type='U' select name from sysobjects where xtype='U' 其中type或xtype值:U = 用户表 S = 系统表 V = 视图 FN = 标量函数 TF = 表函数 P = 存储过程 TR = 触发器 D = 默认值或 DEFAULT 约束 PK = PRIMARY KEY 约束 F = FOREIG…
之前经常在程序中拼接sql语句,其实我们也可以在存储过程中拼接sql 语句,动态的执行~~ 代码如下: DROP PROCEDURE IF EXISTS SearchByDoctor;CREATE PROCEDURE SearchByDoctor( IN DoctorId VARCHAR(50), IN deptId VARCHAR(50), IN beginDate VARCHAR(20), IN endDate VARCHAR(20), IN StandDeptId VARCHAR(50),…
查询数据库中所有表名 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';…