Re: CREATE TABLE AS standard?

Started by Thomas Lockhartabout 26 years ago3 messageshackers
Jump to latest
#1Thomas Lockhart
lockhart@alumni.caltech.edu

I know I use that version my self a lot more than the SELECT INTO
version. We probably got it 'free' from the CREATE VIEW semantics,
as Tom suggested. I tend to use it to 'materialize' a new table when
I'm altering schema (either denormalizing, or normalizing) and need to
convert the type of a column. It's a little handier than seperate CREATE
TABLE and INSERT INTO statements, although it's sematically equivalent.

I implemented CREATE TABLE AS as a semantically clearer version of
SELECT/INTO, which was (afaik) in the original Postgres95 and probably
earlier.

They are equivalent. btw, I assume that Tom used the term "abuse" in
the supportive sense of the word? :)

- Thomas

--
Thomas Lockhart lockhart@alumni.caltech.edu
South Pasadena, California

#2Bruce Momjian
bruce@momjian.us
In reply to: Thomas Lockhart (#1)

I know I use that version my self a lot more than the SELECT INTO
version. We probably got it 'free' from the CREATE VIEW semantics,
as Tom suggested. I tend to use it to 'materialize' a new table when
I'm altering schema (either denormalizing, or normalizing) and need to
convert the type of a column. It's a little handier than separate CREATE
TABLE and INSERT INTO statements, although it's semantically equivalent.

I implemented CREATE TABLE AS as a semantically clearer version of
SELECT/INTO, which was (afaik) in the original Postgres95 and probably
earlier.

They are equivalent. btw, I assume that Tom used the term "abuse" in
the supportive sense of the word? :)

I covered SELECT...INTO in my book, with a short paragraph showing
CREATE TABLE...AS is equivalent. Which one should I use in my book as
the preferred?

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#3Thomas Lockhart
lockhart@alumni.caltech.edu
In reply to: Bruce Momjian (#2)

I covered SELECT...INTO in my book, with a short paragraph showing
CREATE TABLE...AS is equivalent. Which one should I use in my book as
the preferred?

imho CREATE TABLE/AS should be emphasized, since SELECT/INTO hides the
fact that a table gets created, which is a fundamental operation here.
DDF vs DDL vs some other acronym etc etc.

- Thomas

--
Thomas Lockhart lockhart@alumni.caltech.edu
South Pasadena, California