sqlÊý¾Ý¿â£ºÈçºÎÔÚÒ»¸ö±íÖÐÌî¼Ó»òÕßɾ³ýÒ»¸ö×ֶΣ¡
ÈçÒªÔÚÒ»¸öhwsp±íÖÐÌî¼Ó×ֶΣºylxs
alter table hwsp add column ylxs
ALTER TABLE ±í {ADD ADD{COLUMN ×Ö¶ÎÀàÐÍ [ (×Ö³¤)] [NOT NULL] [CONSTRAINT Ë÷Òý ] |
ALTER COLUMN ×Ö¶ÎÀàÐÍ [(×Ö³¤)] |
CONSTRAINT ¶àÖØ×Ö¶ÎË÷Òý } |
DROP DROP{COLUMN ×ֶΠI CONSTRAINT Ë÷ÒýÃû } }
ALTER TABLE Óï¾ä·ÖΪÒÔϼ¸¸ö²¿·Ö£º
²¿·Ö ˵Ã÷
table ÓûÐ޸ĵıíÖ®Ãû³Æ¡£
field ÓûÔÚ±íÄÚÔö¼Ó»òɾ³ýµÄ×ֶεÄÃû³Æ¡£»ò±íÄÚÓû±»Ìæ»»µÄ×Ö¶ÎÃû³Æ¡£
type ×ֶεÄÊý¾ÝÀàÐÍ¡£
size ×ֶεÄ×Ö·û³¤¶È (Îı¾¼°¶þ½øÖÆ×Ö¶Î)¡£
index ×Ö¶ÎË÷Òý¡£ÓûÁ˽â¸ü¶àÓйØÈçºÎ¹¹Ôì±¾Ë÷ÒýµÄÐÅÏ¢£¬Çë¿´ CONSTRAINT×Ӿ䡣
multifieldindex ÓûÔö¼ÓÖÁ±í ÖеĶàÖØ×Ö¶ÎË÷ÒýµÄ¶¨Òå¡£ÓûÁ˽â¸ü¶àÓйØÈçºÎ¹¹Ôì±¾Ë÷ÒýµÄÐÅÏ¢£¬Çë¿´ CONSTRAINT×Ӿ䡣
indexname Óûɾ³ýµÄ¶àÖØ×Ö¶ÎË÷ÒýµÄÃû³Æ¡£
˵Ã÷
ʹÓà ALTER TABLE Óï¾ä£¬¿ÉÓöàÖÖ²»Í¬·½·¨¸ü¸Äµ±Ç°ÒÑ´æÔÚµÄ±í£ºÄã¿ÉÒÔ£º
ʹÓà ADD COLUMN ÔÚ±íÖÐÌí¼ÓеÄ×ֶΡ£ÐèÒªÖ¸¶¨×Ö¶ÎÃû¡¢Êý¾ÝÀàÐÍ¡¢»¹¿ÉÒÔ (¶ÔÎı¾ºÍ¶þ½øÖÆ×Ö¶Î)Ö¸¶¨³¤¶È¡£ÀýÈ磬ÏÂÁÐÓï¾äÔÚÔ±¹¤±íÖÐÔö¼ÓÒ» 25 ¸ö×Ö·ûµÄ¡¢ÃûΪ Notes µÄÎı¾×ֶΣº
ALTER TABLE Employees ADD COLUMN Notes TEXT(25)
Ò²¿ÉÒÔ¶¨Òå´Ë×ֶεÄË÷Òý¡£¹ØÓÚµ¥Ò»×Ö¶ÎË÷ÒýµÄÏêϸÐÅÏ¢£¬Çë²ÎÔÄCONSTRAINT ×Ó¾äÖ÷Ìâ¡£
Èç¹û¶ÔÒ»×Ö¶ÎÖ¸¶¨ NOT NULL£¬ÔòÔÚÕâ×Ö¶ÎÖÐÌí¼ÓµÄмǼ±ØÐëÓÐÓÐЧµÄÊý¾Ý¡£
ʹÓÃALTER COLUMN¸Ä±äÒ»¸öµ±Ç°×ֶεÄÊý¾ÝÀàÐÍ£¬ÐèÒªÖ¸¶¨×Ö¶ÎÃû¡¢ÐÂÊý¾ÝÀàÐÍ¡¢»¹¿ÉÒÔ (¶ÔÎı¾ºÍ¶þ½øÖÆ×Ö¶Î)Ö¸¶¨³¤¶È¡£ÀýÈ磬ÏÂÁÐÓï¾ä°Ñ¹ÍÔ±±íÖÐÒ»¸ö×ֶεÄÊý¾ÝÀàÐÍ, ±»³ÆΪZipCode£¨×î³õ±»¶¨ÒåΪÕûÊý£©£¬¸Ä±ä³ÉÒ»¸ö10×Ö·ûÎı¾×ֶΣº
ALTER TABLE Employees ALTER COLUMN ZipCode TEXT(10)
ʹÓà ADD CONSTRAINT Ìí¼Ó¶àÖØ×Ö¶ÎË÷Òý¡£¹ØÓÚ¶àÖØ×Ö¶ÎË÷ÒýµÄÏêϸÐÅÏ¢£¬Çë²ÎÔÄ CONSTRAINT ×Ó¾äÖ÷Ìâ¡£
ʹÓà DROP COLUMN ɾ³ý×ֶΡ£Ö»ÒªÖ¸¶¨Óûɾ³ýµÄ×Ö¶ÎÃû¼´¿É¡£
ʹÓà DROP CONSTRAINT ɾ³ý¶àÖØ×Ö¶ÎË÷Òý¡£Ö»ÒªÔÚ CONSTRAINT ±£Áô×ÖºóÃæÖ¸¶¨Ë÷ÒýÃû¼´¿É¡£
--------------------------------------------------------------------------------
×¢Òâ
²»ÄÜͬʱÌí¼Ó»òɾ³ýÒ»¸öÒÔÉϵÄ×ֶλòË÷Òý¡£
Äã¿ÉÒÔʹÓà CREATE INDEX Óï¾äÔÚÒ»¸ö±íÖÐÔö¼ÓÒ»¸öµ¥×ֶλò¶àÖØ×ֶΣ¬Ä㻹¿ÉÒÔʹÓà ALTER TABLE »ò DROP Óï¾äɾ
Ïà¹ØÎĵµ£º
/********************************
¹¦ÄÜ£º»ñÈ¡±íµÄ¿Õ¼ä·Ö²¼Çé¿ö
**********************************/
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tablespaceinfo]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
create table tablespaceinfo   ......
--ÔÚÈÕ³£Î¬»¤£¬¿ª·¢Öг£Óöµ½Ð´Ò»ÏµÁнṹÀàÐ͵ÄsqlÓï¾ä£¬ºÜ·³ºÜÀÛÆäʵ¿ÉÒÔ
--ÀûÓÃSQL*PLUS»·¾³ÃüÁî Éú³É½Å±¾Îļþ
set heading off --¹Ø±ÕÁеıêÌâ
set feedback off --¹Ø±Õ·´À¡ÐÅÏ¢
  ......
ºÍjava.lang.IllegalArgumentException: org.hibernate.QueryException: JPA-style positional param was not an integral ordinalÕ½¶·ÁË°ëÌ죬º¹°¡£¡
ʹÓÃjpa + strut+ hibernate ¾Í±¨org.hibernate.QueryException: JPA-style positional param was not an integral ordinal
Ò»°ã°ÑhqlÓï¾äдÔÚÒ»ÐУ¬»áºÜ³¤£¬ÔÚideÖÐÐèÒ ......
select top ÿҳÏÔʾµÄ¼Ç¼Êý * from topic where id not in (select top £¨µ±Ç°µÄÒ³Êý-1£©×ÿҳÏÔʾµÄ¼Ç¼Êý id from topic order by id desc) order by id desc
select top ÿҳÏÔʾµÄ¼Ç¼Êý * from topic where id not in (select top £¨µ±Ç°µÄÒ³Êý-1£©×ÿҳÏÔʾµÄ¼Ç¼Êý id from topic order by id desc) ......