select column_name,column_comment,data_type from information_schema.columns where table_name='查询表名称' and table_schema='数据库名称' 通过以上语句可以查到数据库表的字段属性 end~…
1. select a.* from ALL_TAB_COMMENTS a --查表名和表中文名select a.* from ALL_TAB_COLUMNS a --查询表字段属性select a.* from ALL_COL_COMMENTS a --查询表字段名称 2. dba_tables.all_tables和user_tables的区别 dba_tables : 系统里所有的表的信息,需要DBA权限才能查询all_tables : 当前用户有权限的表的信息(只要对某个表有任何权限,…
1.查找单个字段 select 字段名,count(*) from table group by 字段名 having count(*) > 1 2.查找组合字段: SELECT TEST_NAME1,TEST_NAME2,COUNT(*) FROM table GROUP BY TEST_NAME1,TEST_NAME2 HAVING COUNT(*) > 1…
-- SQL Server 2008 SELECT 表名 = d.name, 表说明 = case when a.colorder=1 then isnull(f.value,'') else '' end, 字段序号 = a.colorder, 字段名 = a.name, 标识 = case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end, 主键 = case when exists(SELECT 1 F…
直切正题 1.表tb中字段num最大的数据 {pc:get $sql="select * from tb where num=(select MAX(num) from tb)"}****************{/pc} 2.表tb中字段num不重复的数据,并按照num从大到小排序 {pc:get $sql="select distinct num from tb order by num desc"}***********{/pc} 用到这个主要是,我的需求添加…
[1]MySQL中查询某表中字段的数据类型 (1)DESC 表名: (2)DESCRIBE 表名: (3)SHOW COLUMNS FROM 表名: 应用示例: DESC cfg_acct_free_res; DESCRIBE cfg_acct_free_res; SHOW COLUMNS FROM cfg_acct_free_res; Good Good Study, Day Day Up. 顺序 选择 循环 总结…
查看表字段.类型.注释 SELECT A.COLUMN_NAME,B.comments,A.DATA_TYPE FROM USER_TAB_COLUMNS A LEFT JOIN user_col_comments B ON A.TABLE_NAME=B.table_name AND A.COLUMN_NAME=B.column_name WHERE A.TABLE_NAME = '表名' ORDER BY A.COLUMN_ID; 获取表字段 select * from user_tab_co…
查询表名 SELECT tablename FROM pg_tables WHERE tablename NOT LIKE 'pg%' AND tablename NOT LIKE 'sql_%' ORDER BY tablename; 或者 select tablename from pg_tables where schemaname='public' 查询表结构 select col.table_schema, col.table_name, col.ordinal_position, c…
select b.name from dbo.syscomments a, dbo.sysobjects b where a.id=b.id and b.xtype='p' and a.text like '%@tempGoods%' order by name xtype 代表类型 C = CHECK 约束D = 默认值或 DEFAULT 约束F = FOREIGN KEY 约束L = 日志FN = 标量函数IF = 内嵌表函数P = 存储过程PK = PRIMARY KEY 约束(类型是…
SELECT TOP (500) ID, Personname, Personcode, Telphone, Fraction into temp3 FROM Records AS a WHERE (LEN(Personcode) = 18 OR LEN(Personcode) = 15) AND (NOT EXISTS (SELECT 1 AS Expr1 FROM Records WHERE (Personname = a.Personname) AND (Fraction > a.Frac…
select (select relname from pg_class where oid=a.attrelid) relname , () as comment from pg_class where oid=a.attrelid) as table_name, a.attname as column_name, format_type(a.atttypid,a.atttypmod) as data_type, ( end)data_length, ( then 'Y' else 'N' e…
create procedure proc_view_cloumns ( ) ) AS select b.name,a.value,c.name, b.max_length from sys.extended_properties a, sys.columns b,sys.types c where a.major_id = OBJECT_ID(@tableName) and a.major_id = b.object_id and a.minor_id = b.column_id and b.…
select --*tcl.column_name,cc.comments col_comments,data_type,case data_type when 'NUMBER' then '('||data_precision||','||data_scale||')' when 'VARCHAR2' then to_char(char_length) when 'CHAR' then to_char(char_length) when 'DATE' then '' else 'no' end…