Re: Why isn't it allowed to create an index in a schema

From: Chris Mair <chrisnospam(at)1006(dot)org>
To: Jorge Godoy <jgodoy(at)gmail(dot)com>
Cc: PostgreSQL General ML <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why isn't it allowed to create an index in a schema
Date: 2006-11-12 13:16:26
Message-ID: 20061112141626.3c0b7fb8.chrisnospam@1006.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I'd like to know if there's any reasoning for not allowing creating an index
> inside the same schema where the table is. For example, if I have a
> multi-company database where each company has its own schema and its employees
> table, shouldn't I have a different index for each of those? What if I have
> some slightly different columns on some of these tables?
>
> ================================================================================
> teste=# create schema testing;
> CREATE SCHEMA
> teste=# create table testing.testing123 (something serial primary key, otherthing float);
> NOTICE: CREATE TABLE will create implicit sequence "testing123_something_seq" for serial column "testing123.something"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "testing123_pkey" for table "testing123"
> CREATE TABLE
> teste=# create index testing.testing123_index on testing.testing123 (otherthing);
> ERROR: syntax error at or near "." no caracter 21
> LINHA 1: create index testing.testing123_index on testing.testing123 ...
> ^
> teste=#
> ================================================================================
>
>
> (I wouldn't mind if the autogenerated index for the PK was created on the
> public schema if no specific name was supplied.)
>
>
> This would also help identifying all objects to make a certain feature
> available and where they belong to on the database...

Just say
create index testing123_index on testing.testing123 (otherthing);
and you'll otain exactly what you want (see below).

Bye, Chris.

chris=> create schema testing;
CREATE SCHEMA
chris=> create table testing.testing123 (something serial primary key, otherthing float);
NOTICE: CREATE TABLE will create implicit sequence "testing123_something_seq" for serial column "testing123.something"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "testing123_pkey" for table "testing123"
CREATE TABLE
chris=> create index testing123_index on testing.testing123 (otherthing);
CREATE INDEX
chris=> \di *.*
List of relations
Schema | Name | Type | Owner | Table
---------+------------------+-------+-------+------------
testing | testing123_index | index | chris | testing123
testing | testing123_pkey | index | chris | testing123
(2 rows)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Verite 2006-11-12 13:43:44 Re: encoding advice requested
Previous Message Andrus 2006-11-12 12:21:46 Re: Why overlaps is not working