mysqlÖÐÓÃÃüÁîÐ޸ıí½á¹¹µÄ·½·¨
ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec …]
alter_specification:
ADD [COLUMN] create_definition [FIRST | AFTER column_name ]
or ADD INDEX [index_name] (index_col_name,…)
or ADD PRIMARY KEY (index_col_name,…)
or ADD UNIQUE [index_name] (index_col_name,…)
or ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}
or CHANGE [COLUMN] old_col_name create_definition
or MODIFY [COLUMN] create_definition
or DROP [COLUMN] col_name
or DROP PRIMARY KEY
or DROP INDEX index_name
or RENAME [AS] new_tbl_name
or table_options
ALTER TABLEÔÊÐíÄãÐÞ¸ÄÒ»¸öÏÖÓбíµÄ½á¹¹¡£ÀýÈ磬Äã¿ÉÒÔÔö¼Ó»òɾ³ýÁС¢´´Ôì»òÏûÈ¥Ë÷Òý¡¢¸Ä±äÏÖÓÐÁеÄÀàÐÍ¡¢»òÖØÐÂÃüÃûÁлò±í±¾Éí¡£ÄãÒ²Äܸıä±íµÄ×¢ÊͺͱíµÄÀàÐÍ¡£¼û7.7 CREATE TABLE¾ä·¨¡£
Èç¹ûÄãʹÓÃALTER TABLEÐÞ¸ÄÒ»¸öÁÐ˵Ã÷µ«ÊÇDESCRIBE tbl_nameÏÔʾÄãµÄÁв¢Ã»Óб»Ð޸ģ¬Õâ¿ÉÄÜÊÇMySQLÒòΪÔÚ7.7.1 Òþº¬µÄÁÐ˵Ã÷¸Ä±äÖÐÃèÊöµÄÔÒòÖ®Ò»¶øºöÂÔÁËÄãµÄÐ޸ġ£ÀýÈ磬Èç¹ûÄãÊÔͼ½«Ò»¸öVARCHAR¸ÄΪCHAR£¬MySQL½«ÈÔȻʹÓÃVARCHAR£¬Èç¹û±í°ü º¬ÆäËû±ä³¤µÄÁС£
ALTER TABLEͨ¹ýÖÆ×÷ÔÀ´±íµÄÒ»¸öÁÙʱ¸±±¾À´¹¤×÷¡£ÐÞ¸ÄÔÚ¸±±¾ÉÏÊ©ÐУ¬È»ºóÔÀ´µÄ±í±»É¾³ý²¢ÇÒÖØÐÂÃüÃûÒ»¸öеġ£ÕâÑù×öʹµÃËùÓеÄÐÞ¸Ä×Ô¶¯µØתÏòµ½ÐÂ±í£¬Ã» ÓÐÈκÎʧ°ÜµÄÐ޸ġ£µ±ALTER TABLEÕýÔÚÖ´ÐÐʱ£¬ÔÀ´µÄ×À¿É±»ÆäËû¿Í»§¶ÁÈ¡¡£¸üкÍдÈë±í±»ÑÓ³Ùµ½Ð±í×¼±¸ºÃÁËΪֹ¡£
ΪÁËʹÓÃALTER TABLE£¬ÄãÐèÒªÔÚ±íÉϵÄselect¡¢insert¡¢delete¡¢update¡¢createºÍdropµÄȨÏÞ¡£
IGNOREÊÇMySQL¶ÔANSI SQL92 µÄÒ»¸öÀ©³ä£¬Èç¹ûÔÚбíÖеÄΨһ¼üÉÏÓÐÖظ´£¬Ëü¿ØÖÆALTER TABLEÈçºÎ¹¤×÷¡£Èç¹ûIGNOREû±»Ö¸¶¨£¬¸±±¾±»·ÅÆú²¢ÇÒ»Ö¸´Ô×´¡£Èç¹ûIGNORE±»Ö¸¶¨£¬ÄÇô¶ÔΨһ¼üÓÐÖظ´µÄÐУ¬Ö»ÓÐʹÓõÚÒ»ÐУ»ÆäÓ౻ɾ³ý¡£
Äã¿ÉÒÔÔÚµ¥¸öALTER TABLEÓï¾äÖз¢³ö¶à¸öADD¡¢ALTER¡¢DROPºÍCHANGE×Ӿ䡣ÕâÊÇMySQL¶ÔANSI SQL92µÄÒ»¸öÀ©³ä£¬SQL92ÔÚÿ¸öALTER TABLEÓï¾äÖÐÖ»ÔÊÐíÒ»¸ö×Ӿ䡣
CHANGE col_name¡¢DROP col_nameºÍDROP INDEXÊÇMySQL¶Ô ANSI SQL92 µÄÀ©³ä¡£
MODIFYÊÇ Oracle ¶ÔALTER TABLEµÄÀ©³ä¡£
¿ÉÑ¡µÄ´ÊCOLUM
Ïà¹ØÎĵµ£º
ÕªÒª£ºMySQLÊÇÒ»¸ö¸ßËٶȡ¢¸ßÐÔÄÜ¡¢¶àÏ̵߳ĹØϵÐÍÊý¾Ý¿â¹ÜÀíϵͳ£¬ÊÊÓÃƽ̨¶à£¬¿ÉÀ©Õ¹ÐÔÇ¿¡£ÔÚʵ¼ÊÉú²ú»·¾³ÖУ¬²¿ÊðºÍʵÏÖ¾ßÓÐÒ»¶¨¸ºÔؾùºâ¹¦ÄܵÄMySQL·þÎñÆ÷
¼¯Èº£¬¶ÔÓÚÌá¸ßÓû§Êý¾Ý¿âÓ¦ÓÃϵͳµÄÐÔÄÜ¡¢ËٶȺÍÎȶ¨ÐÔ¾ßÓÐÃ÷ÏÔµÄ×÷Óᣱ¾ÎļòÒª½éÉÜÁËÔÚFreeBSD
7.0-ReleaseϵͳÉϲ¿ÊðʵÏÖMySQL·þÎñÆ÷
¼¯ÈºµÄ·½°¸£¬²¢¶Ô¿É ......
ÓÉÓÚMySQLÄ¿Ç°×ֶεÄĬÈÏÖµ²»Ö§³Öº¯Êý£¬ËùÒÔÒÔ
create_time datetime default now()
µÄÐÎʽÉèÖÃĬÈÏÖµÊDz»¿ÉÄܵġ£
´úÌæµÄ·½°¸ÊÇʹÓÃTIMESTAMPÀàÐÍ´úÌæDATETIMEÀàÐÍ¡£
TIMESTAMPÁÐÀàÐÍ×Ô¶¯µØÓõ±Ç°µÄÈÕÆÚºÍʱ¼ä±ê¼ÇINSERT»òUPDATEµÄ²Ù×÷¡£
Èç¹ûÓжà¸öTIMESTAMPÁУ¬Ö»ÓеÚÒ»¸ö×Ô¶¯¸üС£
×Ô¶¯¸üеÚÒ»¸öTIMESTAMPÁÐÔÚÏ ......
try
{
string _conStr = "Driver={MySQL ODBC 3.51
Driver};server=localhost;database=test;uid=test;password=1;option=3";
& ......
Hibernate ÅäÖÃͨ¹ýc3p0Á¬½ÓMYSQL
** ÐèÒªµÄ°ü: c3p0_versionxx.jar
** hibernate.cfg.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
&n ......