Mots clés : sqlsql-serversql-server-2005sql-server-2000sql
94
ALTER TABLE {TABLENAME} ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL} CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE} WITH VALUES
ALTER TABLE SomeTable ADD SomeCol Bit NULL --Or NOT NULL. CONSTRAINT D_SomeTable_SomeCol --When Omitted a Default-Constraint Name is autogenerated. DEFAULT (0)--Optional Default-Constraint. WITH VALUES --Add if Column is Nullable and you want the Default Value for Existing Records.
84
ALTER TABLE Protocols ADD ProtocolTypeID int NOT NULL DEFAULT(1) GO
78
ALTER TABLE table ADD column BIT -- Demonstration with NULL-able column added CONSTRAINT Constraint_name DEFAULT 0 WITH VALUES
69
ALTER TABLE <table name> ADD <new column name> <data type> NOT NULL GO ALTER TABLE <table name> ADD CONSTRAINT <constraint name> DEFAULT <default value> FOR <new column name> GO
50
ALTER TABLE MYTABLE ADD MYNEWCOLUMN VARCHAR(200) DEFAULT 'SNUGGLES'