Inserting into table with a Default column value

ta1yn

New Member
I have created a table with a default column value \[code\]male\[/code\]\[code\]CREATE TABLE Persons (name varchar(20), age int, sex varchar(5) default 'male')\[/code\]Insert statement #1:\[code\]INSERT INTO Persons values('Bob', 20)\[/code\]Insert statement #2:\[code\]INSERT INTO Persons(name,sex) values('Bob', 20)\[/code\]When I try to insert the values into \[code\]Persons\[/code\] table using the insert statement #1, I get the error shown below\[quote\] column name or number of supplied values does not match table definition\[/quote\]But when I insert into \[code\]Persons\[/code\] using statement #2, it successfully executes. Can some please explain why this happens?
 
Top