Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
You can simply omit the fields list, but then you have to specify the value of every fields in the right order.
table:
Code:
create table demo(
ikey integer not null,
xcomment varchar(100),
xuser varchar(100) not null,
hpass varchar(255) not null,
constraint pk_demo primary key (ikey)
);
and then:
Code:
insert into demo
(ikey, xcomment, xuser, hpass)
values
(1, null, 'tripy', 'ha350s');
is the same than
Code:
insert into demo
values
(1, null, 'tripy', 'ha350s');
Now, depending of your DB ,(I assume mysql here) I don't know how an auto_increment field would be handled.
Maybe you'd need to give a NULL value to respect the fields orders, I don't know.
I see that mysql allows the use of a keyword named DEFAULT, and it's probably what you'll need.
Given that ikey is with auto_increment
Code:
insert into demo
values
(DEFAULT, null, 'tripy', 'ha350s');
__________________
Only a biker knows why a dog sticks his head out the window.
|