Users Pricing

forum

Home Forums Inserting into table with a Default column value – MindStick

Inserting into table with a Default column value

Anonymous User 2108 04 May 2013
Hi Everyone!

I have created a table with a default column value male

CREATE TABLE Persons 
 (name varchar(20), 
  age int, 
  sex varchar(5) default 'male')

INSERT INTO Persons values('Bob', 20)
Insert statement #2:

INSERT INTO Persons(name,sex) values('Bob', 20)
When I try to insert the values into Persons table using the insert statement #1, I get the error shown below

column name or number of supplied values does not match table definition

But when I insert into Persons using statement #2, it successfully executes.

Can some please explain why this happens?

Thanks in advance!

1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md