How can I create a column and copy the values and structure from an existing column from another table?
My try:
CREATE COLUMN database.table.column SELECT * FROM database.table2.column
If you are copy to a new table:
CREATE TABLE newtable
SELECT columnname
FROM table2
If you want to add a new column to an existing table, you need
ALTER TABLE existing_table ADD column new_col . . .
And you need to update existing_table based on keys
UPDATE existing_table
SET new_col = (
SELECT columnname
FROM table1
WHERE . . .
)
Depends on how your situation, there is also a lazy way:
SELECT existing_table.*, table1.columnname
FROM existing_table, table1
WHERE . . .
To copy full table structure and values
SELECT * INTO NewTableName FROM ExistingTableName
To copy specific structure and value
SELECT ExistingTableName.Column1,ExistingTableName.Column2 INTO NewTableName FROM ExistingTableName