Re: Where do I enter commands?
От | Andrew Sullivan |
---|---|
Тема | Re: Where do I enter commands? |
Дата | |
Msg-id | 20151025151029.GA1228@crankycanuck.ca обсуждение исходный текст |
Ответ на | Re: Where do I enter commands? (David Blomstrom <david.blomstrom@gmail.com>) |
Список | pgsql-general |
On Sun, Oct 25, 2015 at 07:57:48AM -0700, David Blomstrom wrote: > In phpMyAdmin, I've become accustomed to simply copying existing tables, > then adding, deleting and renaming columns as needed. Oh! Interesting. I suspect you're actually _undermining_ your ability to use the database (because often when you copy a table it's a sign that you're using the database like a spreadsheet, and you're giving up a lot of functionality that way). But, suppose you're wanting to do that, then here's the easy way to do it: --- if you want the same table structure without the data CREATE TABLE newtable AS SELECT * FROM oldtable WHERE 1=0; -- if you want the same table with some data CREATE TABLE newtable AS SELECT columns, you, want, in, order FROM oldtable [WHERE conditions]; If you want only some columns or new order or something, the WHERE clause in the latter statement should be 1=0. It makes a null set always. Handy trick. > I can see PostgreSQL is going to have a learning curve - hopefully shorter > than the years it took me to learn MySQL - but it looks interesting. It should be much easier. You have the basics from MySQL already. Consistency and rigour are the changes ;-) A -- Andrew Sullivan ajs@crankycanuck.ca
В списке pgsql-general по дате отправления: