Search Postgresql Archives

Re: Creating Primary Key after CREATE TABLE: Is Sequence created?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/27/2013 01:16 PM, Monosij wrote:
Ok I understand about not programming to LCD.

I just initially wanted to play around with creating tables / indexes / fks
and import some data before moving to next steps.

I did want to have some control over namimg conventions.

For eg. with creating PK id and sequence with 1 statement as:
id serial primary key
I have a vague idea how the primary key and sequence was named but no
control on it.

However if I could control the naming convention from here I would be ok
with it.

Would there be a way to control the naming of the id and sequence from the
create table statement?

Using serial, remembering that serial is basically a macro that does what is shown here:

http://www.postgresql.org/docs/9.3/interactive/datatype-numeric.html#DATATYPE-SERIAL

Name your table and id column to get the desired sequence name.

Otherwise do as shown in the expanded example in the link above and wrap multiple statements in a transaction and create the sequence and id as you want.


Thank you.



--
View this message in context: http://postgresql.1045698.n5.nabble.com/Creating-Primary-Key-after-CREATE-TABLE-Is-Sequence-created-tp5772633p5772651.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.




--
Adrian Klaver
adrian.klaver@xxxxxxxxx


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux