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 |
|
sql0009
Starting Member
3 Posts |
Posted - 2009-03-05 : 12:35:28
|
| What does the following command do?Create table mytab (name char(10) NULL, age int(3) default ‘none supplied’, address varchar(20), primary key (name));It creates a my tab table with a name, age, and address columns with name being set as a primary key and age having a default value but what does NULL do to name? |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-03-05 : 12:41:04
|
| makes sure that NULL values are not allowed in the column. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-05 : 12:52:28
|
quote: Originally posted by sql0009 What does the following command do?Create table mytab (name char(10) NULL, age int(3) default ‘none supplied’, address varchar(20), primary key (name));It creates a my tab table with a name, age, and address columns with name being set as a primary key and age having a default value but what does NULL do to name?
why are you making name NULLable if its primary key? |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2009-03-05 : 14:01:39
|
quote: Originally posted by sql0009 What does the following command do?Create table mytab (name char(10) NULL, age int(3) default ‘none supplied’, address varchar(20), primary key (name));It creates a my tab table with a name, age, and address columns with name being set as a primary key and age having a default value but what does NULL do to name?
That create table statement won't do anything. If has at least three errors that I see:1. int(3) is not a valid data type2. 'none supplied' is an invalid default for column age, since it cannot be converted to an integer.3. You cannot define a primary key on nullable column name.CODO ERGO SUM |
 |
|
|
|
|
|
|
|