>>mysql :
1、查看所有表名:
show tables [from db_name];
2、查看字段信息
SHOW FULL COLUMNS FROM db_name.table_name
获取以下信息
Field :字段名
Type:字段类型
Collation:字符集(mysql 5.0以上有)
Null :是否可以为NULL
Key:索引(PRI,unique,index)
Default:缺省值
Extra:额外(是否 auto_increment)
Privileges:权限
Comment:备注(mysql 5.0以上有)
>>sqlserver
1、查看所有用户建表名
select name from Sysobjects where xtype='U'order by name;
2、查看字段信息
SELECT
a.colorder as 字段顺序号,
a.name as 字段名称,
a.collation as 排序字符集,
是否自动增长数字=casewhen COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then 'yes'else 'no' end,
是否主键=case whenexists(SELECT 1 FROM sysobjects where xtype='PK' and name in (
SELECT name FROM sysindexes WHERE indid in(
SELECT indid FROM sysindexkeys WHERE id =a.id AND colid=a.colid
))) then 'yes' else 'no' end,
字段类型=b.name,
字段长度=a.length,
字段字符长度=COLUMNPROPERTY(a.id,a.name,'PRECISION'),
小数位数=isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0),
是否为NULL=casewhen a.isnullable=1 then 'yes'else 'no' end,
缺省值=isnull(e.text,'')
FROM syscolumns a
left join systypes b on a.xtype=b.xusertype
inner join sysobjects d on a.id=d.id and(d.xtype='U' or d.xtype='V') and d.name<>'dtproperties'
left join syscomments e on a.cdefault=e.id
where d.name='purchase_medicine'
order by a.colorder
>>oracle
//查询所有表的信息
select * from dba_tables
//查询所有视图的信息
select * from dba_views
//查询指定表或视图的列信息
select * from dba_tab_columns
注意:当要创建包含Sys表空间的对象时,需要赋 相应表或视图的权限给它。
如 需要创建查询包含表和视图的 视图
create or replace view v_tableview
as
select owner , table_name from dba_tables
union all
select owner , view_name from dba_views
则需要
grant select on sys.dba_tables to "用户"
grant select on sys.dba_views to "用户"