I have a table. I want to add two columns to this table.
I tried it like this:
SELECT *
into
dbo.mytable_Audit
from dbo.mytable
But, I need two colums to mytable_Audit, how do I add them in sybase 15-2 ASE?
I have a table. I want to add two columns to this table.
I tried it like this:
SELECT *
into
dbo.mytable_Audit
from dbo.mytable
But, I need two colums to mytable_Audit, how do I add them in sybase 15-2 ASE?
You can also add columns to existing tables by using the alter table
command. For example, to add two new int
columns to mytable_Audit
, one with a default value, and the other as NULL:
alter table mytable_Audit add col1 int default 0, col2 int NULL
You get as much columns in your new table, as you have in the existing one. Name, type and order will be inherited from dbo.mytable
.
To add an additional column to the output, just add a column to the select:
select 0 as col1, * into dbo.mytable_AUDIT from dbo.mytable;
This adds a column of type integer as the first column in the new table.