← Back to team overview

drizzle-discuss team mailing list archive

Re: CREATE TABLE LIKE

 



Brian Aker wrote:
Hi!

In this case:

CREATE TEMPORARY TABLE t1 (
  id INT NOT NULL
, padding VARCHAR(200) NOT NULL
);

CREATE TABLE t2 LIKE t1;

Should t2 be a TEMPORARY table or not? What if the engine for t1 can't be TEMPORARY? Toss an error?

It seems like to me that either we should toss and error, or t2 should be identical to t1.

Thoughts? Opinions?

According to the SQL standard, LIKE can be specified multiple times, and mangled with regular column definitions. So, this is more like specifying a list of column names and types, and not about temporary/permanent type.

AFAIU, the following statement is legal:

CREATE GLOBAL TEMPORARY TABLE tx (k INTEGER PRIMARY KEY, LIKE t1, LIKE t2);

ie, create a table consisting of column k and all columns from table t1 and t2.

Thanks,
Roy



References