SQl Óï¾ä(³£¼û) н¨,ɾ³ý,Ð޸ıí½á¹¹
н¨±í£º
create table [±íÃû]
(
[×Ô¶¯±àºÅ×Ö¶Î] int IDENTITY (1,1) PRIMARY KEY ,
[×Ö¶Î1] nVarChar(50) default 'ĬÈÏÖµ' null ,
[×Ö¶Î2] ntext null ,
[×Ö¶Î3] datetime,
[×Ö¶Î4] money null ,
[×Ö¶Î5] int default 0,
[×Ö¶Î6] Decimal (12,4) default 0,
[×Ö¶Î7] image null ,
)
ɾ³ý±í£º
Drop table [±íÃû]
²åÈëÊý¾Ý£º
INSERT INTO [±íÃû] (×Ö¶Î1,×Ö¶Î2) VALUES (100,'51WINDOWS.NET')
ɾ³ýÊý¾Ý£º
DELETE from [±íÃû] WHERE [×Ö¶ÎÃû]>100
¸üÐÂÊý¾Ý£º
UPDATE [±íÃû] SET [×Ö¶Î1] = 200,[×Ö¶Î2] = '51WINDOWS.NET' WHERE [×Ö¶ÎÈý] = 'HAIWA'
ÐÂÔö×ֶΣº
ALTER TABLE [±íÃû] ADD [×Ö¶ÎÃû] NVARCHAR (50) NULL
ɾ³ý×ֶΣº
ALTER TABLE [±íÃû] DROP COLUMN [×Ö¶ÎÃû]
ÐÞ¸Ä×ֶΣº
ALTER TABLE [±íÃû] ALTER COLUMN [×Ö¶ÎÃû] NVARCHAR (50) NULL
ÖØÃüÃû±í£º(Access ÖØÃüÃû±í£¬Çë²Î¿¼ÎÄÕ£ºÔÚAccessÊý¾Ý¿âÖÐÖØÃüÃû±í)
sp_rename '±íÃû', 'бíÃû', 'OBJECT'
н¨Ô¼Êø£º
ALTER TABLE [±íÃû] ADD CONSTRAINT Ô¼ÊøÃû CHECK ([Ô¼Êø×Ö¶Î] <= '2000-1-1')
ɾ³ýÔ¼Êø£º
ALTER TABLE [±íÃû] DROP CONSTRAINT Ô¼ÊøÃû
н¨Ä¬ÈÏÖµ
ALTER TABLE [±íÃû] ADD CONSTRAINT ĬÈÏÖµÃû DEFAULT '51WINDOWS.NET' FOR [×Ö¶ÎÃû]
ɾ³ýĬÈÏÖµ
ALTER TABLE [±íÃû] DROP CONSTRAINT ĬÈÏÖµÃû
ÁíÍâÒÔÉϵÄÖ»ÊÇSQLµÄÓï·¨ÔÚ ACCESS Ï´󲿷ÝÒ²¶¼ÊÇÒ»ÑùµÄ
ÏîÒ»Ïî²éÔÄ,²¢¾×Ô¼ºÊ¹ÓÃÑéÖ¤,È·ÈÏÔÚaccess Êý¾Ý¿âÖÐÌí¼Ó×Ô¶¯±àºÅ×Ö¶ÎʹÓÃÒÔÏ·½·¨±È½ÏºÏÊÊ: create table Êý¾Ý±íÃû³Æ (id counter constraint primarykey primary key) ÐèҪעÒâµÄµØ·½ÊÇ:µÚ¶þ¸öprimaryÖмäÓпոñ,ÁíÍâ,¹Ø¼ü×Ö²»Çø·Ö´óСд. ÁíÍâ×Ô¼º×î½ü·¢ÏÖµÄÒ»ÖÖ·½·¨ÊÇ: sql="create table mytb (id autoincrement(25,1) primary key,age int)" sql2="create table testtb (id autoincrement,age int,email char, primary key (id))" ÆäÖÐÔÚaccessÖÐ,autoincrementΪ×Ô¶¯±àºÅÀàÐÍ×Ö¶Î,(25,1)·Ö±ðΪ³õʼֵ¼°²½³¤Öµ,Èç¹û²»Ð´µÄ»°,ĬÈÏÊÇ1,1,primary keyÖ¸¶¨ÁËÖ÷¼ü,ÒÔÉÏʾÀý,Á½ÖÖÖ¸¶¨·½·¨¶¼¿ÉÒÔ
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
SELECT * into newtable
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\aaaa.xls";User ID=Admin;Password=;Extended properties=Excel 11.0')...[Sheet1$]
/******* µ¼³öµ½excel
¡¡¡¡exec master..xp_cmdshell 'bcp settledb.dbo.shanghu out c:\temp1.xls -c -q -s"gnetdata/gnetdata" - ......
£¨1£©Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò£¨Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ£©
oracleµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒÖÁ×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í£¨»ù´¡±í£©½«×îÏȱ»´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£Èç¹ûÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ, ÄǾÍÐèҪѡÔñ½»²æ±í(intersection table)×÷Ϊ»ù´ ......
²»ÖªµÀÕâÑùµÄÒªÇóÄܲ»ÄÜʵÏÖ£¿
±ÈÈçÎÒÓÐÒ»ÕűíT1£¬ÀïÃæÖ»ÓÐÒ»¸ö×Ö¶Î1
ÀïÃæÓÐ100Ìõ¼Ç¼£¬ÈçÏÂËùʾ£º
×Ö¶Î1
A1
A2
A3
A4
...
A100
ÎÒÏëÓÃÒ»ÌõSQLÏÔʾÕâÑùµÄ½á¹û
µÚÒ»ÁÐ µÚ¶þÁÐ ... µÚÊ®ÁÐ
A1 A11 &nb ......