Alter table in Sybase

Using alter command, we can change the structure of the table. Following changes can be done on tables:

  • Add and Drop columns
  • Add and Drop constraints
  • Add null columns
  • Change locking scheme
  • Convert column datatypes
  • Partition or Unpartition tables
  • Increase or decrease the column length


alter table table_name
[add column_name datatype [identity | null |
not null] [, column_name datatype [identity
|null | not null]]]
[drop column_name [, column_name]
[modify column_name {[data_type]
[[null] | [not null]]}
[, column_name datatype [null | not null]]]

Adding columns to table:

1> alter table student
2> add address varchar(100) null
3> go

Modifying the columns:

1> alter table student
2> modify address varchar(99)
3> go

Adding Constraints:

1>alter table student
2>add constraint age_chk
3>check (age < 3) 4>go

Dropping Constraints:

1>alter table student
2>drop constraint age_chk

Related Posts

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by k2schools
%d bloggers like this: