Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create table in postgreSQL

People also ask

How do you create a table in Pgadmin?

Login to phpPgAdmin and reach "Public" database. Now click on "Create table" in the right hand pane of the phpPgAdmin window. In the next window, supply name and number of columns you want to create and click "Next". In the next window, supply name of the column, data type and click "Create".

How do you create a table in Greenplum?

To be able to create a table, you must have USAGE privilege on all column types or the type in the OF clause, respectively. If you specify a schema name, Greenplum creates the table in the specified schema. Otherwise Greenplum creates the table in the current schema.

Does Postgres have tables?

To create a table, you use the aptly named CREATE TABLE command. In this command you specify at least a name for the new table, the names of the columns and the data type of each column.


First the bigint(20) not null auto_increment will not work, simply use bigserial primary key. Then datetime is timestamp in PostgreSQL. All in all:

CREATE TABLE article (
    article_id bigserial primary key,
    article_name varchar(20) NOT NULL,
    article_desc text NOT NULL,
    date_added timestamp default NULL
);

-- Table: "user"

-- DROP TABLE "user";

CREATE TABLE "user"
(
  id bigserial NOT NULL,
  name text NOT NULL,
  email character varying(20) NOT NULL,
  password text NOT NULL,
  CONSTRAINT user_pkey PRIMARY KEY (id)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE "user"
  OWNER TO postgres;

Replace bigint(20) not null auto_increment by bigserial not null and datetime by timestamp