I searched for this here and on google and surprisingly couldn’t find an answer. I tried to create syntax to submit to mysql that would create multiple tables with the same columns, but it returned an error. Can you point out what is wrong with my syntax, or if this is even possible?
CREATE TABLE news, life
(
id int PRIMARY KEY AUTO_INCREMENT ,
name varchar( 30 ) ,
email varchar( 50 ) ,
COMMENT text,
datetime datetime,
ip varchar( 20 )
)
It’s not possible like that.
Think about your table design. This sounds like you should consider creating a single table and adding another column
typethat will benewsorlife(or a reference to another table defining types).If you really need two tables, create your first table:
and then
Indexes and constraints (
UNIQUE,PRIMARY KEY,FOREIGN KEY) will not be copied though. You will have to handle them yourself.