HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to add function to particular column in while creating table in Postgres?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
whilepostgrescolumncreatingfunctionhowparticulartableadd

Problem

I want to add a function to particular column while creating a table in PostgreSQL. After creating table, it has to generate auto generated id when we insert values into to the table.

Solution

There is serial and bigserial numeric type to autogenerate numbers i.e. autoincrement.

If you want to have custom function then you need to create trigger functions first and assign it to the trigger on insert.

More in the postgresql docs:

http://www.postgresql.org/docs/9.4/static/datatype-numeric.html

Context

StackExchange Database Administrators Q#106664, answer score: 3

Revisions (0)

No revisions yet.