×ÔÔö×ֶεÄ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 Server ÖеÄÈÕÖ¾£¬¼õСÊý¾Ý¿âÎļþ´óС
dump transaction Êý¾Ý¿âÃû with no_log
backup log Êý¾Ý¿âÃû with no_log
dbcc shrinkdatabase(Êý¾Ý¿âÃû)
exec sp_dboption 'Êý¾Ý¿âÃû', 'autoshrink', 'true'
×ÔÔöÁв»ÄÜÖ±½ÓÐ޸ģ¬±ØÐ뽫ÔÓÐIDÁÐɾ³ý£¬È»ºóÖØÐÂÌí¼ÓÒ»ÁоßÓÐidentityÊôÐÔµÄID×ֶΣ¬Óï¾äÈçÏÂ
alter table ±íÃû
drop column ID
alter table ±íÃû
add ID int identity(1,1)
ÐÞ¸ÄÈÕÆÚ×Ö¶ÎΪDatatimeÀàÐÍ£¬Ê×ÏÈÒª±£Ö¤±íÖÐÎÞÊý¾Ý£¬»òÏÖÓÐÊý¾Ý¿ÉÒÔÖ±½Óת»»ÎªdatetimeÀàÐÍ£¬·ñÔòÐÞ¸Ä×Ö¶ÎÀàÐ;ͻáʧ°Ü¡£
alter table ±íÃû
alter column ÈÕÆÚ×Ö¶ÎÃû datetime
1, ʹÓÃÒ»¸öÊý¾Ý¿â֮ǰҪÒýÓÃËû£ºuse Êý¾Ý¿âÃû
2£¬ exists()ÅжÏ×Ó²éѯµÄ½á¹ûÊÇ·ñ´æÔÚ£¬·µ»Øtrue or false
3, object_id('¶ÔÏóÃû') ·µ»Ø¸Ã¶ÔÏóÃû¶ÔÓ¦µÄId,¸Ãid´æ´¢ÔÚsysobjects±íÖС£
4£¬ ½¨±íʱ×Ô¶¯½¨Á¢Ö÷¼üÔ¼Êø£ºcreate table a(b char(4),c int,constraint Ö÷¼üÃû primary key(c))
»òÕߣºcreate table a(a char(
Ïà¹ØÎĵµ£º
¾¹ýºÃ¼¸ÌìµÄ·ÜÕ½£¬JDBCÖÕÓڳɹ¦Á¬½ÓÁËSQL Server 2000£¬ÆÚ¼ä×ßÁ˲»ÉÙÍä·£¬ÔÚÕâÀï·ÖÏíÎÒµÄÒ»µã¾Ñé
Ò»¡¢ÎҵĻ·¾³
Windows XP+JDK6u15+Microsoft SQL Server 2000£¨SP4£©+JCreator
ÎÒÏÈÔÚÍøÉÏÏÂÔØÊý¾Ý¿âÇý¶¯³ÌÐò£¬Ä¿Â¼ÏÂÓÐÈý¸ö°ümsbase.jar mssqlserver.jar msutil.jar
1 ......
ÔÚijЩ³¡ºÏÏ£¬´æ´¢¹ý³Ì»ò´¥·¢Æ÷ÀïµÄSQLÓï¾äÐèÒª¶¯Ì¬Éú³É¡£OracleµÄDBMS_SQL°ü¿ÉÒÔÓÃÀ´Ö´Ðж¯Ì¬SQLÓï¾ä¡£±¾ÎÄͨ¹ýÒ»¸ö¼òµ¥µÄÀý×ÓÀ´Õ¹Ê¾ÈçºÎÀûÓÃDBMS_SQL°üÖ´Ðж¯Ì¬SQLÓï¾ä£º
DECLARE
v_cursor NUMBER;
v_stat NUMBER;
& ......
Sql Server ÖÐÒ»¸ö·Ç³£Ç¿´óµÄÈÕÆÚ¸ñʽ»¯º¯Êý
Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
Select CONVERT(varchar(100), GETDATE(), 1): 05/16/06
Select CONVERT(varchar(100), GETDATE(), 2): 06.05.16
Select CONVERT(varchar(100), GETDATE(), 3): 16/05/06
Select CONVE ......
SQL Server CE 2.0µÄÈ«ÃûÊÇSQL Server 2000 Windows CE Edition version 2.0¡£
Àý×Ó1£º¹«Ë¾ÅÉÈËÈ¥²Ö¿âÑé»õ¡¢µã»õ£¬¿ÉÒÔ°ÑÇ嵥ͬ²½µ½Pocket PCÉÏ£¬È»ºóÔÚ²Ö¿âÀïÃæÖ±½ÓÔÚPPCÉÏÃæupdate£¬»Øµ½¹«Ë¾Ò»Í¬²½¾Í¿ÉÒÔÁË¡£·ñÔò°´ÕÕÔÏÈ×ö·¨£¬ÐèÒªÏÈ´òÓ¡Ò»ÕÅÇåµ¥£¬»ØÀ´ÒÔºóÔÙ¼ÈëÒ»±é¡£
Àý×Ó2£ºÁªÏëÅÉÈËÉÏÃÅÀ´ÐÞµçÄÔ£¬ÒÔÇ°×ÜÊÇ´ ......