I know I can do something like this:
CREATE TABLE new_table AS (
SELECT field1, field2, field3
FROM my_table
)
I'm wondering how do I add more columns to this create table SQL
, that are not from my_table
, but instead ones that I would write my self and which would be unique to this new_table
only.
I know I could just make the table with the above SQL
and then additionaly (after the command is completed) add the necessary columns, but am wondering if this all could be done in one command, maybe something like this (tried it like that, but didn't work):
CREATE TABLE new_table AS (
(SELECT field1, field2, field3
FROM my_table),
additional_field1 INTEGER NOT NULL DEFAULT 1,
additional_field2 VARCHAR(20) NOT NULL DEFAULT 1
)
my_table
and additionaly I want to add my fields which, will be default to some value (just addedDEFAULT
to my sql example above)