Leandro DUTRA wrote:
> Não vou lembrar da sintaxe exata, mas de fato é um ponto fraco do
> PostgreSQL.
>
Não. Existe uma maneira elegante de fazer isso em um comando só. É claro
que se você quiser separar os comandos para adicionar as restrições
depois fica a seu critério.
euler=# create table foo (a serial, b text not null, c char(3) not null,
primary key(a) using index tablespace tbsp2, unique(c) using index
tablespace tbsp2) tablespace tbsp1;
NOTA: CREATE TABLE criará sequência implícita "foo_a_seq" para coluna
serial "foo.a"
NOTA: CREATE TABLE / PRIMARY KEY criará índice implícito "foo_pkey" na
tabela "foo"
NOTA: CREATE TABLE / UNIQUE criará índice implícito "foo_c_key" na
tabela "foo"
CREATE TABLE
euler=# \d foo
Tabela "public.foo"
Coluna | Tipo | Modificadores
--------+--------------+-------------------------------------------------
a | integer | not null default nextval('foo_a_seq'::regclass)
b | text | not null
c | character(3) | not null
Índices:
"foo_pkey" PRIMARY KEY, btree (a), tablespace "tbsp2"
"foo_c_key" UNIQUE, btree (c), tablespace "tbsp2"
Tablespace: "tbsp1"
PS> Marcondes, o nome correto é *PostgreSQL* ou simplesmente *Postgres*.
--
Euler Taveira de Oliveira
http://www.timbira.com/
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral