MYSQL Íâ¼ü¶¨ÒåÓëʹÓÃ
ÔÚMySQL 3.23.44°æ±¾ºó£¬InnoDBÒýÇæÀàÐ͵ıíÖ§³ÖÁËÍâ¼üÔ¼Êø¡£
Íâ¼üµÄʹÓÃÌõ¼þ£º
1.Á½¸ö±í±ØÐëÊÇInnoDB±í£¬MyISAM±íÔÝʱ²»Ö§³ÖÍâ¼ü£¨¾Ý˵ÒÔºóµÄ°æ±¾ÓпÉÄÜÖ§³Ö£¬µ«ÖÁÉÙÄ¿Ç°²»Ö§³Ö£©£»
2.Íâ¼üÁбØÐ뽨Á¢ÁËË÷Òý£¬MySQL 4.1.2ÒÔºóµÄ°æ±¾ÔÚ½¨Á¢Íâ¼üʱ»á×Ô¶¯´´½¨Ë÷Òý£¬µ«Èç¹ûÔÚ½ÏÔçµÄ°æ±¾ÔòÐèÒªÏÔʾ½¨Á¢£»
3.Íâ¼ü¹ØϵµÄÁ½¸ö±íµÄÁбØÐëÊÇÊý¾ÝÀàÐÍÏàËÆ£¬Ò²¾ÍÊÇ¿ÉÒÔÏ໥ת»»ÀàÐ͵ÄÁУ¬±ÈÈçintºÍtinyint¿ÉÒÔ£¬¶øintºÍcharÔò²»¿ÉÒÔ£»
Íâ¼üµÄºÃ´¦£º¿ÉÒÔʹµÃÁ½Õűí¹ØÁª£¬±£Ö¤Êý¾ÝµÄÒ»ÖÂÐÔºÍʵÏÖһЩ¼¶Áª²Ù×÷£»
Íâ¼üµÄ¶¨ÒåÓï·¨£º
[CONSTRAINT symbol] FOREIGN KEY [id] (index_col_name, ...)
REFERENCES tbl_name (index_col_name, ...)
[ON DELETE {RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT}]
[ON UPDATE {RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT}]
¸ÃÓï·¨¿ÉÒÔÔÚ CREATE TABLE ºÍ ALTER TABLE ʱʹÓã¬Èç¹û²»Ö¸¶¨CONSTRAINT symbol£¬MYSQL»á×Ô¶¯Éú³ÉÒ»¸öÃû×Ö¡£
ON DELETE¡¢ON UPDATE±íʾʼþ´¥·¢ÏÞÖÆ£¬¿ÉÉè²ÎÊý£º
RESTRICT£¨ÏÞÖÆÍâ±íÖеÄÍâ¼ü¸Ä¶¯£©
CASCADE£¨¸úËæÍâ¼ü¸Ä¶¯£©
SET NULL£¨Éè¿ÕÖµ£©
SET DEFAULT£¨ÉèĬÈÏÖµ£©
NO ACTION£¨ÎÞ¶¯×÷£¬Ä¬Èϵģ©
¸ã¸öÀý×Ó£¬¼òµ¥ÑÝʾһÏÂʹÓã¬×ödageºÍxiaodiÁ½¸ö±í£¬´ó¸ç±íÊÇÖ÷¼ü£¬Ð¡µÜ±íÊÇÍâ¼ü£º
½¨±í£º
1
CREATE
TABLE
`dage` (
2
`id`
int
(
11
)
NOT
NULL
auto_increment,
3
`name`
varchar
(
32
)
default
''
,
4
PRIMARY
KEY
(`id`)
5
) ENGINE
=
InnoDB
DEFAULT
CHARSET
=
latin1£»
6
7
CREATE
TABLE
`xiaodi` (
8
`id`
int
(
11
)
NOT
NULL
auto_increment,
9
`dage_id`
int
(
11
)
default
NULL
,
10
`name`
varchar
(
32
)
default
''
,
11
PRIMARY
KEY
(`id`),
12
KEY
`dage_id` (`dage_id`),
13
&nbs
Ïà¹ØÎĵµ£º
1.´´½¨±í£º
create table groupTable(dept varchar(6),phone varchar(20),amount int);
2.²åÈë²âÊÔÊý¾Ý£º
insert groupTable
select 'ÓªÒµ²¿',8001,20 union all
select 'ÓªÒµ²¿',8002,30 union all
se ......
×öÈí¼þÊý¾Ý¿â±Ø²»¿ÉÉÙ£¬ÎÒÑ¡ÔñÁËMySQL¡£
Ê×Ïȵ½http://dev.mysql.com/downloads/ÏÂÔغÃMySQL5.1ºÍMySQL GUI TOOLS
ϵ½µçÄÔÉÏ,È»ºó°²×°£¬ÏÈ×°5.1ÔÙ×°gui tools ,һ·ȷ¶¨°É¡£
ŪºÃºó£¬µã¿ªMySQL Query Browser£¬¾Í¿ÉÒÔ²Ù×÷Êý¾Ý¿âÁË¡£
MySQLµÄÇý¶¯³ÌÐòÊÇGUITOOLS°²×°Ä¿Â¼/java/libϵÄmysql-connector-java-5.0.4-bin.ja ......
×î½üÓöµ½Ò»¸öÐèÇóÒªÔÚlinuxÏÂÓÃjava µ÷ÓÃmysql¿Í»§¶ËÔ¶³ÌµÇ½mysql·þÎñÆ÷£¬´Ó¿Í»§¶Ë»úÆ÷µ¼Èëmysql½Å±¾£¬´Ómysql·þÎñÆ÷¶Ëµ¼³ö±íÖеÄÊý¾Ý¡£ÒÔÏÂÊÇÓõ½µÄÖ÷Òª·½·¨£º
Java ´úÂë
/**
* µ¼ÈëÊý¾Ý
* @param ½Å±¾µÄµØÖ·ºÍÃû³Æ
* @return ÊÇ·ñ³ ......
my.iniÎļþÅäÖ㺠[mysql] default-character-set=GBK #´Ë´¦µÄ±àÂëÊÇMySQL¿ØÖÆ̨ÏÔʾµÄ±àÂ뷽ʽ£¬Ó¦¸ÃÉèÖÃΪGBK [mysqld] default-character-set=utf8 #´Ë´¦µÄ±àÂëÊÇMySQLÊý¾Ý´æ´¢µÄ¸ñʽ£¬Ó¦¸ÃÉèÖÃΪutf8£¬¿ÉÒÔ´æ´¢ÊÀ½çÉϾø´ó¶àÊý×Ö·û ......
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 [ ......