Create tables based on another table

Поиск
Список
Период
Сортировка
Искать
От
Anshuman Kanwar
Тема
Create tables based on another table
Дата
Msg-id
571354A131635E42AE6C1F584F5F9B3A011EFB71@cabfranc.ad.corp.expertcity.com
Список
Дерево обсуждения
Create tables based on another table Anshuman Kanwar <ansh@expertcity.com>
Re: Create tables based on another table Oliver Elphick <olly@lfix.co.uk>
Hi all,

I want to have a table that lists all other tables in a database. For
example:


table Project_List (
	project_id   integer;
	project_name text;    
      project_type text;  -- can have values simple/complex
);

Now I want to automatically create a new table in the database whenever an
entry is made in this "Project_List". Based on "project_type", this new
table could have 2 different structures.


if $project_type is "simple" 

	create table $project_name (     -- I want this to be filled in 
      	                           -- from the new row just added 
            	                     -- in the above table
		file_id integer;
		file_name text;
	);
else

	create table $project_name (     

		file_id integer;
		file_name text;
		file_chksum text;
	);
fi


What mechanism can I use to accomplish this ? Could anyone point me to any
documentation ?

Thanks,
-ansh
В списке pgsql-novice по дате отправления
От: santoso berkah
Дата:
От: Oliver Elphick
Дата:
FAQ