Re: Entering data in serial column

Поиск
Список
Период
Сортировка
От david@netventures.com.au
Тема Re: Entering data in serial column
Дата
Msg-id Pine.LNX.4.21.0109292346380.5363-100000@rapt.netventures.com.au
обсуждение исходный текст
Ответ на Entering data in serial column  (Devrim GUNDUZ <devrim@oper.metu.edu.tr>)
Список pgsql-sql
Hi There,

If you omit the column names, the values are assumed to follow the order
of the column names in the table definition. So if you have the columns
with default values at the end of the table definition, then you don't
need to insert a value for them.  Same as in C.

It is better practice though to name the columns, as then if you rebuild
your schema, or alter the table (Effecting the order of the columns) then
the insert statement retains its meaning.

If you have 40 columns, then you are going to have an awfull lot of
trouble maintaining the insert statement anyway.  Whats an extra few lines
of SQL with the column names (they will probably help you keep track of
which one you are up to anyway).


Devrim GUNDUZ <devrim@oper.metu.edu.tr> Wrote:
> Now, since id is a serial, while inserting data into info I write:
> 
> INSERT INTO info (name,surname,address) VALUES ('$name','$surname',
> '#address');
> 
> Is there a shorter way of doing this? I mean, if I had 40 fields in this
> table, would I have to write all the fields? I mean, is there a syntax
> beginning like
> 
> INSERT INTO info VALUES (....

--
David Stanaway




В списке pgsql-sql по дате отправления:

Предыдущее
От: Devrim GUNDUZ
Дата:
Сообщение: Entering data in serial column
Следующее
От: Miguel González
Дата:
Сообщение: PostgreSQL downloads