| From: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
|---|---|
| To: | Monosij <monosij(dot)forums(at)gmail(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Creating Primary Key after CREATE TABLE: Is Sequence created? |
| Date: | 2013-09-27 20:26:52 |
| Message-ID: | 5245EA0C.6060904@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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(dot)klaver(at)gmail(dot)com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | John R Pierce | 2013-09-27 20:42:55 | Re: Building with MinGW issue |
| Previous Message | Monosij | 2013-09-27 20:16:52 | Re: Creating Primary Key after CREATE TABLE: Is Sequence created? |