Skip site navigation (1) Skip section navigation (2)

Re: inserting values like in mySQL

From: Chris Smith <csmith(at)squiz(dot)net>
To: postgresql <pgsql-novice(at)postgresql(dot)org>
Subject: Re: inserting values like in mySQL
Date: 2001-05-22 23:24:02
Message-ID: (view raw, whole thread or download thread mbox)
Lists: 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:
>>CREATE TEMP TABLE tempo (test bool, id serial);
>>INSERT INTO tempo values (true);
>>SELECT * from tempo;
>>  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 

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 :)

In response to


pgsql-novice by date

Next:From: Nabil SayeghDate: 2001-05-23 01:36:08
Subject: Re: inserting values like in mySQL
Previous:From: Chris SmithDate: 2001-05-22 22:51:10
Subject: Re: inserting values like in mySQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group