MySQL内存表和临时表
时间:2021-07-01 10:21:17
帮助过:28人阅读
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