0

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?

Geeky Guy
  • 9,229
  • 4
  • 42
  • 62
niru dyogi
  • 619
  • 5
  • 14
  • 37

2 Answers2

7

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
Mike Gardner
  • 6,611
  • 5
  • 24
  • 34
0

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.

jboi
  • 11,324
  • 4
  • 36
  • 43