On 2011-04-06, Carlos Mennens <carlos.mennens@xxxxxxxxx> wrote: > I've only been using PostgreSQL since Oct 2010 and it's my first > experience with SQL or any ORDBMS. I've searched on the web and been > creating my own database users, databases, tables from scratch which > has been interesting to say the least but now I would like to know if > this is possible in SQL or PostgreSQL since I can't find anything > online that shows me how to do so. I've created a table called 'users' > and I have it configured as follows: > > CREATE TABLE users > ( > id integer PRIMARY KEY UNIQUE NOT NULL, --ID > fname character varying(40) NOT NULL, --First name > lname character varying(40) NOT NULL, --Last name > email character varying NOT NULL, --email address > office integer NOT NULL, --Office number > dob date NOT NULL, --Date of birth > age integer NOT NULL --Age > ) > ; > > Is there a way in SQL I can have the users 'age' be auto adjusted > based on the 'id' & 'dob'? I'm not sure how id can be used here. Running this each morning will keep it current. for the normal definition of human age. update user set age=extract('year' from age(dob)) where age is distinct from extract('year' from age(dob)); a cleaner way is to create a view and present a computed age column in the view -- ââ 100% natural -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general