Re: I have some questions...
От | Michal Taborsky |
---|---|
Тема | Re: I have some questions... |
Дата | |
Msg-id | 410E46A1.9090408@taborsky.cz обсуждение исходный текст |
Ответ на | Re: I have some questions... (Prabu Subroto <prabu_subroto@yahoo.com>) |
Список | pgsql-general |
Prabu Subroto wrote: > I still have problem with a new column into the > current table (salesreport table). Because I can not > find in the documentation of postgres how to define a > new column into a current table "AFTER A CERTAIN > COLUMN". > on MySQL, I can do easily like this : > " > alter table salesreport add column emoicon(....) after > report; > " > How can I do this on postgres? You can't AFAIK. And you don't want to, either. I guess I know why you ask about this--you are using "SELECT * FROM table" and then are accessing "the fourth column". This, however, is bad practice and you are asking for trouble. Don't count on the database engine to return columns in any particular order, because the order is not guaranteed (same as is not guaranteed the order of rows, if you don't specify an ORDER BY clause.) You should always specify column names, if your application is accessing columns according to their position in returned result. You have two possibilities: a) Specify exact column names and order in query: SELECT column1, column2 FROM table Then it is safe to print $row[0] and $row[1] (in PHP array form, just an example) b) Use named columns interface: SELECT * FROM table Then in application level use $row['column1'] (again PHP example) -- I think most languages provide this functionality -- Michal Taborsky http://www.taborsky.cz
В списке pgsql-general по дате отправления: