Re: inserting values like in mySQL - Mailing list pgsql-novice

From Chris Smith
Subject Re: inserting values like in mySQL
Date
Msg-id 4.3.2.7.2.20010523092000.00b6fd70@cooee.cybersydney.com.au
Whole thread Raw
In response to Re: inserting values like in mySQL  (Nabil Sayegh <nsmail@sayegh.de>)
Responses Re: inserting values like in mySQL  (Nabil Sayegh <nsmail@sayegh.de>)
List pgsql-novice
Me again,

>> > In mySQL it was like this:
>> >
>> > insert into users values ('','peter','my_pass');
>> >
>> > In PostGreSQL this does not work. The only thing that works is
>> >
>> > insert into users (name,pass) values ('peter','my_pass');
>>
>>Yes, thats not nice in postgresql. But there is a workaround.
>>Put the 'default' fields at the end:
>>
>>---------------8<---------------------
>>CREATE TEMP TABLE tempo (test bool, id serial);
>>
>>INSERT INTO tempo values (true);
>>
>>SELECT * from tempo;
>>---------------8<---------------------
>>
>>  test | id
>>------+----
>>  t    |  1
>>(1 row)
>>
>>Hope it helps.
>>
>>P.S.: I'd really like postgresql to behave like mysql in this context
>
>Huh? Mysql doesn't like it either (at least in 3.23). Anyway, it's not
>standard.

What I meant was...
You can do it, just not with int or serial values (try it with a text,
varchar, char, bool field), or any field with the UNIQUE constraint. Same
as mysql, you can't insert '' into an int field or an auto_increment field.

Bye again :)


pgsql-novice by date:

Previous
From: Chris Smith
Date:
Subject: Re: inserting values like in mySQL
Next
From: Nabil Sayegh
Date:
Subject: Re: inserting values like in mySQL