欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

关于DM达梦数据库,获取数据表结构信息、数据表创建语句、主键等信息的sql

程序员文章站 2022-06-09 19:50:08
1、获取数据表中的字段名、类型、长度、描述select name,reftype,length,descrip from (select distinct A.COLUMN_ID as id, A.column_name name,A.data_type reftype,A.data_length as length,B.comments descripfrom user_tab_columns A,user_col_comments B ,all_cons_columns C,USER_TAB.....

1、获取数据表中的字段名、类型、长度、描述

 select name,reftype,length,descrip from (
select distinct A.COLUMN_ID as id, A.column_name name,A.data_type reftype,A.data_length as length,B.comments descrip 
from user_tab_columns A,user_col_comments B ,all_cons_columns C,USER_TAB_COMMENTS D  where a.COLUMN_NAME=b.column_name and A.Table_Name = B.Table_Name 
 and A.Table_Name = D.Table_Name and (A.TABLE_NAME=c.table_name) and  A.Table_Name='tablename' ORDER BY id )

2、获取数据表创建语句

 schname:模式名 tablename:表名
 
 call SP_TABLEDEF(schname,tablename)

3、获取数据表主键信息

Select  col.column_name from all_constraints con,all_cons_columns col where
 con.constraint_name=col.constraint_name and con.constraint_type='P' and col.table_name='tablename'

 

 

本文地址:https://blog.csdn.net/xsfqh/article/details/108999361