Search Postgresql Archives

Re: best way to reference tables

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

 



Alvaro Herrera <alvherre@xxxxxxxxxxxxxx> writes:
> On Tue, Aug 09, 2005 at 04:01:33PM -0400, Tom Lane wrote:
>> Yeah, you can store the pg_class OID of the table,

> Maybe it is possible to use a column of type regclass to store it.  Not
> sure exactly what advantage that would give, but it's an idea.

Hmm, that's a cute idea.

regression=# create table tablist (tabid regclass);
CREATE TABLE
regression=# create table mytab(f1 int);
CREATE TABLE
regression=# insert into tablist values ('mytab');
INSERT 0 1
regression=# select * from tablist;
 tabid
-------
 mytab
(1 row)

regression=# alter table mytab rename to histab;
ALTER TABLE
regression=# select * from tablist;
 tabid
--------
 histab
(1 row)

regression=# create schema s1;
CREATE SCHEMA
regression=# alter table histab set schema s1;
ALTER TABLE
regression=# select * from tablist;
   tabid
-----------
 s1.histab
(1 row)

regression=# drop table s1.histab;
DROP TABLE
regression=# select * from tablist;
 tabid
-------
 82301
(1 row)

regression=#

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

[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