获取sql Server中的数据库名、表名 、字段名
---------------------------------------------------------------------------------------
1.获取所有数据库名:
SELECT name FROM Master..SysDatabases ORDER BY name
2.获取所有表名:
SELECT name FROM Databasename..SysObjects Where XType='U' ORDER BY name
XType='U':表示所有用户表;
XType='S':表示所有系统表;
3.获取所有字段名:
SELECT name FROM SysColumns WHERE ID=Object_ID('tablename')
获取ACCESS数据库中的 查询、窗体、表名、报表、模块、宏
---------------------------------------------------------------------------
查询:
SELECT MSysObjects.name FROM MsysObjects WHERE (left([name],1)<>"~") AND (MSysObjects.Type)=5 ORDER BY MSysObjects.name;
窗体:
SELECT MSysObjects.name FROM MsysObjects WHERE (left([name],1)<>"~") AND (MSysObjects.Type)=-32768 ORDER BY MSysObjects.name;
表名:
SELECT MSysObjects.name FROM MsysObjects WHERE (left([name],1)<>"~") AND (left$([name],4) <> "Msys") AND (MSysObjects.Type)=1 ORDER BY MSysObjects.name;
报表:
SELECT MSysObjects.name FROM MsysObjects WHERE (left([name],1)<>"~") AND (MSysObjects.Type)= -32764 ORDER BY MSysObjects.name;
模块:
SELECT MSysObjects.name FROM MsysObjects WHERE (left([name],1)<>"~") AND (MSysObjects.Type)= -32761 ORDER BY MSysObjects.name;
宏:
SELECT MSysObjects.name FROM MsysObjects WHERE (left([name],1)<>"~") AND (MSysObjects.Type)= -32766 ORDER BY MSysObjects.name;
Access所有对象的列表及创建日期、修改日期:
SELECT msysobjects.name,msysobjects.DateUpdate,msysobjects.DateCreate FROM msysobjects
WHERE (((msysobjects.Type) like "-3276*" Or (msysobjects.Type)=1 Or (msysobjects.Type)=4 Or (msysobjects.Type)=5) AND ((msysobjects.Flags)=0)) OR (((msysobjects.Flags)=537919488)) ORDER BY msysobjects.Type,msysobjects.Flags
通过对数据库的系统表对象来判断网站中使用的是何种数据库格式(sqlServer、ACCESS)
------------------------------------------------------------------------------------------------------------
1、(select count(*) from sysobjects)>=0 如果查询结果成立,则是使用sql数据库;
2、(select count(*) from Msysaccessobjects)>=0 如果查询结果成立,则是ACCESS数据库。
以上是内存溢出为你收集整理的获取SqlServer和Access中的表名等对象名称全部内容,希望文章能够帮你解决获取SqlServer和Access中的表名等对象名称所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)