phpMyAdmin SQL - 临时表
phpMyAdmin SQL - Temporary Tables
我需要一些帮助,以根据当前 table 中的数据在 phpMyAdmin sql 中创建临时 table。例如,我有一个名为 Animals
的 table,其中包含多个列,其中一列称为 Animal_Size
,我需要创建一个名为 [=13] 的临时 table =] 由 Animals
table 中的动物组成,其中 size
是 small。
有人可以指导我执行此操作的最佳方法吗?
我看过一些示例,但其中很多似乎都不起作用。
如果你需要select所有的小动物变成新的table,你要使用这个查询:
CREATE TABLE small_animals SELECT * FROM animals WHERE animal_size = 'small'
如果您需要真正的临时 table,那么只需将 TEMPORARY 添加到查询中:
CREATE TEMPORARY TABLE small_animals_temp SELECT * FROM animals WHERE animal_size = 'small'
更新:由于 phpMyAdmin 中解析器的问题,在 SELECT
之前添加 AS
,即:
CREATE TABLE small_animals AS SELECT * FROM animals WHERE animal_size = 'small'
Note: A TEMPORARY table is visible only to the current connection, and
is dropped automatically when the connection is closed.
我需要一些帮助,以根据当前 table 中的数据在 phpMyAdmin sql 中创建临时 table。例如,我有一个名为 Animals
的 table,其中包含多个列,其中一列称为 Animal_Size
,我需要创建一个名为 [=13] 的临时 table =] 由 Animals
table 中的动物组成,其中 size
是 small。
有人可以指导我执行此操作的最佳方法吗?
我看过一些示例,但其中很多似乎都不起作用。
如果你需要select所有的小动物变成新的table,你要使用这个查询:
CREATE TABLE small_animals SELECT * FROM animals WHERE animal_size = 'small'
如果您需要真正的临时 table,那么只需将 TEMPORARY 添加到查询中:
CREATE TEMPORARY TABLE small_animals_temp SELECT * FROM animals WHERE animal_size = 'small'
更新:由于 phpMyAdmin 中解析器的问题,在 SELECT
之前添加 AS
,即:
CREATE TABLE small_animals AS SELECT * FROM animals WHERE animal_size = 'small'
Note: A TEMPORARY table is visible only to the current connection, and is dropped automatically when the connection is closed.