SQL: copy a table into another...

Solved
Hello everyone,

The query:
CREATE TABLE TABLE2 AS SELECT * FROM TABLE1 ;
allows me to copy the structure as well as the data from TABLE1 into TABLE2.
Is there a way (query) to copy only the structure (without the data)?

Thank you all for your help.

9 answers

  • Votes
  • Date
  • Descending date
  1. Even cleaner:

    CREATE TABLE table2 LIKE table1

    (Simply copies the structure of table1 by creating table2)
    1. Heu.... on which DBMS? It doesn't work on SQL Server anyway...
    2. Even less on Oracle
    3. encore moi sur PGsql 9.3
    4. @mtk30Je ne peux pas fournir d'informations ou de contenu sur Postgres 9.3.
    5. It works on phpMyAdmin mtk30-