mysql alter table创建外键(Foreign Key) 的语句
ALTER TABLE Order ADD FOREIGN KEY ( userid ) REFERENCES app_user( id )
ON UPDATE RESTRICT
一个表有多个外键的情况:
ALTER TABLE `tablename`
ADD CONSTRAINT `FK_BOOK` FOREIGN KEY (`BOOKID`) REFERENCES `book` (`BOOKID`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `FK_USER` FOREIGN KEY (`USERID`) REFERENCES `user` (`USERID`) ON UPDATE CASCADE;
ALTER TABLE `dbname`.`tblname` ADD CONSTRAINT `FK_NAME` FOREIGN KEY `FK_NAME` (`USERID`)
REFERENCES `USER` (`USERID`)
ON DELETE CASCADE
ON UPDATE CASCADE;
http://www.sofee.cn/blog/2006/08/07/28/
http://hi.baidu.com/jlhh/blog/item/69f9a011accf3c7eca80c48c.html
mysql> show variables;
D:\Dev_tools\mysql-5.0.24a-win32>cd bin
D:\Dev_tools\mysql-5.0.24a-win32\bin>mysqldump zzesweb > D:/zz.sql
D:\Dev_tools\mysql-5.0.24a-win32\bin>
http://www.stephanwiesner.de/
http://www.blogjava.net/max/rss
CREATE TABLE example(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
name VARCHAR(30),
age INT)
<---------------------------> Insert
INSERT INTO example
(name, age) VALUES('Timmy Mellowman', '23' )
<-----------------------------> update
UPDATE example SET age='22' WHERE age='21'
<------------------------------> select
SELECT * FROM example ;
SELECT * FROM example
WHERE name='Sandy Smith' ;
<----------------------------------> delete
DELETE FROM example WHERE age='15'