From: | "Gregory Wood" <gregw(at)com-stock(dot)com> |
---|---|
To: | "Jason" <gee308(at)mediaone(dot)net> |
Cc: | "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: help with serial type |
Date: | 2001-04-26 17:37:46 |
Message-ID: | 006801c0ce77$f6ce5000$7889ffcc@comstock.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> > I'm surprised that works at all... the name of the table is "atable",
isn't
> > it? Try this:
> >
> > INSERT INTO atable (title,name,date) VALUES ('SQL3','Toy',date('now'));
> >
> > Greg
>
> Thanks for the help. I wrote the command out wrong in the post, I did try
the
> one that you wrote out, and it didn't update. I used:
>
> INSERT INTO atable (title,name,date) VALUES ('SQL3','Toy',date('now'));
> Still not sure how to fix it.
I just did this on 7.1 (PostgreSQL 7.1 on i386-unknown-freebsd4.2, compiled
by GCC 2.95.2) and it worked fine:
-----
CREATE TABLE atable (
title VARCHAR(20),
name VARCHAR(20),
id SERIAL PRIMARY KEY
);
ALTER TABLE ADD COLUMN date DATE;
INSERT INTO atable (title,name,date) VALUES ('SQL3','Toy',date('now'));
INSERT INTO atable (title,name,date) VALUES ('SQL3','Toy2',date('now'));
-----
After that I tried SELECT currval('atable_id_seq'); and got the correct
value (2).
> Is it possible to rearrange columns? I looked
> in the tutorial, but didn't find anything useful.
In relational database design, the order of the columns should not matter,
only the data layout of the database (which columns are in which table). To
the best of my knowledge, the only way to reorder the columns physically
would be to recreate the table... you can do a SELECT id,title,name,date
INTO btable FROM atable, and then rename that first table I suppose. Or
rename the table first and then do the SELECT INTO.
From | Date | Subject | |
---|---|---|---|
Next Message | Gregory Wood | 2001-04-26 17:40:30 | Re: help with serial type |
Previous Message | Geoff Caplan | 2001-04-26 17:31:48 | Re: Struggling to change default data location |