orcle 语句 create table book1(name, price) as select book_name, price form book; 
对应的MySQL的语句是什么 create table book1 as select book_name, price form book; 这样在MySQL里可以,但是却不能改属性的名字。

解决方案 »

  1.   


    create table book1 select book_name,price form book;
      

  2.   


    mysql> select * from t1;
    +---+------+---------+
    | a | f    | message |
    +---+------+---------+
    | 1 |    1 | Testing |
    | 2 |    2 | table   |
    | 3 |    3 | t1      |
    +---+------+---------+
    3 rows in set (0.11 sec)mysql>mysql> create table t4 as select a as id,f from t1;
    Query OK, 3 rows affected (0.11 sec)
    Records: 3  Duplicates: 0  Warnings: 0mysql> select * from t4;
    +----+------+
    | id | f    |
    +----+------+
    |  1 |    1 |
    |  2 |    2 |
    |  3 |    3 |
    +----+------+
    3 rows in set (0.00 sec)mysql>
      

  3.   

    mysql> create table book1 as select name as testname from a;
    Query OK, 6 rows affected (0.22 sec)
    Records: 6  Duplicates: 0  Warnings: 0mysql> select * from book1;
    +----------+
    | testname |
    +----------+
    | chen     |
    | chen     |
    | zhao     |
    | sun      |
    | zhao     |
    | chen     |
    +----------+
    6 rows in set (0.00 sec)
      

  4.   

    create table book1(name, price) as select book_name, price form book; -->create table book1 as select book_name as name, price form book;