mysql 视图...
时间:2010-08-13 来源:garcon1986
/****************by garcon1986*******************/
CREATE TABLE IF NOT EXISTS `testtable1` ( `pk_tId` int(11) NOT NULL AUTO_INCREMENT, `firstName` varchar(20) DEFAULT NULL, `lastName` varchar(20) DEFAULT NULL, `age` int(11) DEFAULT NULL, `details` text, PRIMARY KEY (`pk_tId`), UNIQUE KEY `id` (`pk_tId`), FULLTEXT KEY `firstName` (`firstName`,`lastName`,`details`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11; CREATE TABLE IF NOT EXISTS `testtable2` ( `pk_tId` int(11) NOT NULL AUTO_INCREMENT, `firstName` varchar(20) DEFAULT NULL, `lastName` varchar(20) DEFAULT NULL, `age` int(11) DEFAULT NULL, `details` text, PRIMARY KEY (`pk_tId`), UNIQUE KEY `id` (`pk_tId`), FULLTEXT KEY `firstName` (`firstName`,`lastName`,`details`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11; CREATE VIEW v12 AS SELECT t1.firstName, t1.lastName, t1.age, t1.details, t2.firstName, t2.lastName, t2.age, t2.details FROM testtable t1, testtable2 t2; CREATE VIEW v1 AS SELECT t1.pk_tId, t1.firstName, t1.lastName, t1.age, t1.details FROM testtable t1;