Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
johnny1walker
Starting Member
17 Posts |
Posted - 2012-03-09 : 13:18:35
|
| ==>CONSTRAINT DF_NO DEFAULT('TR') kodu altta ilk (1) verdigmdeki yazmak zorundayiz.Ama hoca alttaki (2) gibi yapmaya çalisin diye ödev verdi.how to do As the second code the first code(1) (true)USE test1CREATE TABLE tablo1(no int ,il varchar(40) CONSTRAINT DF_NO DEFAULT('TR'),min tinyint ,mak tinyint ,tck int ,CONSTRAINT PK_NO PRIMARY KEY (no),CONSTRAINT CK_MIN CHECK (min >= 5),CONSTRAINT CK_MAK CHECK (mak <= 25),CONSTRAINT UK_TCK UNIQUE (tck))GO--------------------------------------------(2) (false) to correctUSE test1CREATE TABLE tablo1(no int ,il varchar(40) ,min tinyint ,mak tinyint ,tck int ,CONSTRAINT PK_NO PRIMARY KEY (no),CONSTRAINT CK_MIN CHECK (min >= 5),CONSTRAINT CK_MAK CHECK (mak <= 25),CONSTRAINT UK_TCK UNIQUE (tck)CONSTRAINT DF_NO DEFAULT('TR'))GO |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-03-09 : 13:50:25
|
Yes, the DEFAULT constraint doesn't know which column to be associated with. That is why teh first one works. You can add the other constraints after the "main" table definition because they reference the column specifically.If you want to add the constraint after you can alter the table:ALTER TABLE tablo1 ADD CONSTRAINT DF_NO DEFAULT('TR') FOR il |
 |
|
|
johnny1walker
Starting Member
17 Posts |
Posted - 2012-03-09 : 14:12:58
|
very much thanks.. |
 |
|
|
|
|
|
|
|