Posted By

denakitan on 04/20/12


Tagged

sql table check default server Value add column alter constraint


Versions (?)

SQL - SQL Server - Add Column with Default Value and Check Constraint


 / Published in: SQL
 

URL: http://msdn.microsoft.com/en-us/library/ms190273.aspx

Example of SQL syntax to add a new column to an existing table, define a default value to the columns for the existing rows and also add a check constraint to limit the values that the column can hold.

  1. ALTER TABLE
  2. GhibliMovies
  3. ADD
  4. Director VARCHAR(255) NULL
  5. CONSTRAINT
  6. director_check CHECK (Director IN ('Hayao Miyazaki', 'Isao Takahata', 'Yoshifumi Kondo', 'Goro Miyazaki', 'Hiromasa Yonebayashi'))
  7. DEFAULT
  8. 'Hayao Miyazaki' WITH VALUES;

Report this snippet  

You need to login to post a comment.