码迷,mamicode.com
首页 > 数据库 > 详细

MySQL内存表和临时表

时间:2017-02-03 11:04:53      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:table   exist   insert   text   内存   var   learn   adb   rar   

#MySQL内存表和临时表

DROP TABLE IF EXISTS tbl;

CREATE TABLE tbl (
    id INT NOT NULL AUTO_INCREMENT,
    title VARCHAR (50) NOT NULL,
    author VARCHAR (50) NOT NULL,
    PRIMARY KEY (id)
) ENGINE = INNODB DEFAULT CHARSET = utf8;

INSERT INTO tbl(title, author) VALUES(Learn MySQL, John Poul),(Learn Java, Adbul S);

#内存表
DROP TABLE IF EXISTS mmr;

CREATE TEMPORARY TABLE mmr (
    #title TEXT NOT NULL#内存表不支持BLOB/TEXT列
    author VARCHAR (50) NOT NULL
) ENGINE = MEMORY DEFAULT CHARSET = utf8;

INSERT INTO mmr SELECT author FROM tbl;

SELECT author FROM mmr;

#临时表
DROP TABLE IF EXISTS tmp;

CREATE TEMPORARY TABLE tmp (
    title TEXT NOT NULL,
    author VARCHAR (50) NOT NULL
) ENGINE = MYISAM DEFAULT CHARSET = utf8;

INSERT INTO tmp (title, author) SELECT title, author FROM tbl;

SELECT title, author FROM tmp;

MySQL内存表和临时表

标签:table   exist   insert   text   内存   var   learn   adb   rar   

原文地址:http://www.cnblogs.com/xiaowangzhi/p/6362151.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!