Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create column for auto-date in postgresql

Tags:

postgresql

I know that to create a column in mysql is like this

 'date' timestamp not null default CURRENT_TIMESTAMP, 

  how to postgresql?

like image 718
wladyband Avatar asked May 07 '14 12:05

wladyband


People also ask

How do I create a timestamp column in PostgreSQL?

PostgreSQL timestamp example First, create a table that consists of both timestamp the timestamptz columns. Next, set the time zone of the database server to America/Los_Angeles . After that, query data from the timestamp and timestamptz columns. The query returns the same timestamp values as the inserted values.

What is auto increment in PostgreSQL?

PostgreSQL has the data types smallserial, serial and bigserial; these are not true types, but merely a notational convenience for creating unique identifier columns. These are similar to AUTO_INCREMENT property supported by some other databases.

How do I create columns in PostgreSQL?

To list down all tables columns on a specific table in the a PostgreSQL database using psql command-line, you can use \dS your_table_name.


1 Answers

It's the same, you just have to fix the identifier quoting to use SQL standard "identifer quoting":

 "date" timestamp not null default CURRENT_TIMESTAMP, 

but really, you should not use "date" as an identifier.

like image 60
Craig Ringer Avatar answered Sep 17 '22 20:09

Craig Ringer