Hello,
I've seen that postgreSQL tries to follow sql standards as far as possible, 
and that sometimes (often) brings it's own extentions. I've thought of one 
concerning the sql command create table like.
As far as I've understood the documentation, one can create a table using 
another table as a template.
Could it be possible then to add the possibility just to rename columns using 
this command.
Here is an example to make my words a better meaning :

create table some_lib 
(
  some_code serial primary key,
  some_text text
);

Now, I want a second table that has the same structure, I can do it two ways :

create table any_lib
(
  any_code serial primary key,
  any_text text
);

or 

create table any_lib like (some_lib including constraints);

If I use the second option, the fields of any_lib will be named some_code and 
some_text, which is not what I want, so I will have to use 
alter table any_lib rename column some_code to any_code;
alter table any_lib rename column some_text to any_text;

Could it be possible to have a syntax that would allow to use "create table 
like" to rename fields as well, for example :

create table any_lib like (some_lib including constraints) with names 
(any_code, any_text);

Of course, this is just an example, and the tables schemas used are not big 
enough to make it needed in this case, it is just here to illustrate my 
meaning.
If one or more fields have to keep the name of the original table, then one 
could use one keyword (maybe "default") like this :
create table any_lib like (some_lib including constraints) with names 
(default, any_text);
This way, the first field would be named some_code...
What do you think of this ?

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to