标签:ibm war 控制 查询 语言 mysql 科学 tab 修改
拷贝表结果,表结构+ 表数据一起拷贝
mysql> select * from t1;
+----+-------+--------+
| id | name | gender |
+----+-------+--------+
| 1 | david | NULL |
| 2 | alang | NULL |
| 3 | alex | female |
+----+-------+--------+
3 rows in set (0.05 sec)
mysql> create table t2 select * from t1;
Query OK, 3 rows affected (0.04 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select * from t2;
+----+-------+--------+
| id | name | gender |
+----+-------+--------+
| 1 | david | NULL |
| 2 | alang | NULL |
| 3 | alex | female |
+----+-------+--------+
3 rows in set (0.00 sec)
条件为假时,只拷贝表结构,不拷贝表数据,新表数据查不到任何记录
mysql> select * from t1;
+----+-------+--------+
| id | name | gender |
+----+-------+--------+
| 2 | alang | NULL |
| 3 | alex | female |
+----+-------+--------+
2 rows in set (0.00 sec)
mysql> create table t3 select * from t1 where 1=1;
Query OK, 2 rows affected (0.04 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select * from t3;
+----+-------+--------+
| id | name | gender |
+----+-------+--------+
| 2 | alang | NULL |
| 3 | alex | female |
+----+-------+--------+
2 rows in set (0.00 sec)
mysql> create table t4 select * from t1 where 1=2;
Query OK, 0 rows affected (0.06 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> select * from t4;
Empty set (0.00 sec)
mysql> desc t4;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| id | int(11) | NO | | 0 | |
| name | varchar(10) | YES | | NULL | |
| gender | varchar(10) | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.07 sec)
标签:ibm war 控制 查询 语言 mysql 科学 tab 修改
原文地址:https://www.cnblogs.com/daviddd/p/12047358.html