SQL²é±íÃû¡¢×Ö¶ÎÃû¡¢±í˵Ã÷¡¢×Ö¶Î˵Ã÷
SQL ²é¿´ËùÓбíÃû£º
select name from sysobjects where type='U'
²éѯ±íµÄËùÓÐ×Ö¶ÎÃû£º
Select name from syscolumns Where ID=OBJECT_ID('±íÃû')
select * from information_schema.tables
select * from information_schema.views
select * from information_schema.columns
ACCESS
²é¿´ËùÓбíÃû£º
select name from MSysObjects where type=1 and flags=0
MSysObjectsÊÇϵͳ¶ÔÏó£¬Ä¬ÈÏÇé¿öÊÇÒþ²ØµÄ¡£Í¨¹ý¹¤¾ß¡¢Ñ¡Ïî¡¢ÊÓͼ¡¢ÏÔʾ¡¢ÏµÍ³¶ÔÏó¿ÉÒÔʹ֮ÏÔʾ³öÀ´¡£
SQL²éѯ±íµÄ±¸×¢ËµÃ÷
SELECT ±íÃû = case when a.colorder = 1 then d.name
else '' end,
±í˵Ã÷ = case when a.colorder = 1 then isnull(f.value, '')
else '' end
from syscolumns a
inner join sysobjects d
on a.id = d.id
and d.xtype = 'U'
and d.name <> 'sys.extended_properties'
left join sys.extended_properties f
on a.id = f.major_id
and f.minor_id = 0
SQL²éѯ±íµÄËùÓÐ×ֶεı¸×¢ËµÃ÷
SQL_1£º
SELECT Sysobjects.name AS TABLE_NAME, syscolumns.Id, syscolumns.name AS COLUMN_NAME,
systypes.name AS DATA_TYPE, syscolumns.length as CHARACTER_MAXIMUM_LENGTH,
sys.extended_properties.[value] AS COLUMN_DESCRIPTION, syscomments.text as
COLUMN_DEFAULT,syscolumns.isnullable as IS_NULLABLE from syscolumns
INNER JOIN systypes
ON syscolumns.xtype = systypes.xtype
LEFT JOIN sysobjects ON syscolumns.id = syso
Ïà¹ØÎĵµ£º
sql 2005±íµÄ¸´ÖÆÓÐÁ½ÖÖ£ºÒ»ÖÖ¾ÍÊÇ°ÑÕû¸ö±í¸´ÖƹýÈ¥£¬¾ÍºÃÏñ¸´ÖÆÎļþ²¢ÇÒÖØÃüÃû¡£±ðÍâÒ»ÖÖ¾ÍÊǰѱíµÄÄÚÈݸ´Öƹý³ö.
select * into newtable form oldtable;°Ñoldtabel¸´ÖƵ½newtableÇÒnewtable²»´æÔÚ,·ñÔò³ö´í.;
insert into newtable select * from oldtable°ÑoldtableµÄÄÚÈݲåÈëµ½newtable, newtableÒ»¶¨Òª´æÔÚ, ......
ÏÂÔصØÖ·£ºhttp://msftdbprodsamples.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=19353
ÎÒÏÂÔصÄÊÇSQL2008.AdventureWorks_All_Databases.x86.msi£¬±¾²»ÏëÏÂÔØÕâÖÖ°²×°Îļþ£¬µ«½Å±¾Îļþ×ÜÊÇÖ´Ðгö´í£¬ÔÒòû¾ßÌåÉ¡£ÕâÖÖ°²×°Îļþ°²×°ºó»á´´½¨Áù¸ö¿âAdventureWorks¡¢AdventureWorks2008¡¢AdventureWorksDW¡¢Ad ......
USE MASTER
GO
--´´½¨Êý¾Ý¿âÎļþ´æ·ÅĿ¼
EXEC XP_CMDSHELL 'MKDIR D:\LOANSTUMIS'
IF EXISTS(SELECT *
from SYSDATABASES
WHERE NAME = 'LOANSTU')
DROP DATABASE LOANSTU
GO
--´´½¨Êý¾Ý¿â
CREATE DATABASE LOANSTU
ON
(
NAME = 'LOANSTU_DATA',
FILENAME = 'D:\LOANSTUMIS\LOANSTU_DATA.MDF',
......
×÷ÖÐÊý¾Ý¿â¾³£³ö´íËÀËø£¬²¢ÇÒ»¹ÒªÒªÇó½â¾öµ±Ç°µÄËÀËø£¬ÎÊÌâ¶à¶à£»
²ÎÕÕCSDN£¬Öйú·ç(Roy)һƪËÀËøÎÄÕ²¢¸Ä½øÁËÏ£»
/***********************************************************************************************************************
ÕûÀíÈË£ººÚľÑÂÉϵÄÎÏÅ£(lenolotus) ÈÕÆÚ:2009.04.28
************ ......
ÏÈ˵˵ÕâЩÎóÇø¡£Ëùν“ÎóÇø”£¬ÓÐһЩÊÇÐÂÊÖºÜÈÝÒ×·¸µÄ´íÎó»òÕߺÜÈÝÒ׺öÂÔµÄÎÊÌ⣬ÁíÍâһЩ£¬ÔòÊÇÏñ“ºÄ×Ó³ÔÁËÑλá±ä³Éòùòð”Ò»Ñù£¬ÈÃÎÒÃÇ´ÓС¾ÍÈÏΪÊÇÕýÈ·µÄÊÂÇé¡£ÈçÏ£º
1¡¢ ±íÉϲ»¹ÜÓõÃ×ÅÓò»×Å£¬¶¼¼Ó¸ö¾Û¼¯Ë÷Òý¡£
ÎÒÃÇÖªµÀ£¬±íÒÔÁ½ÖÖ·½Ê½×éÖ¯ÎïÀí´æ´¢£ºÓоۼ¯Ë÷ÒýµÄ“¾Û¼¯± ......