postgres create user table code example
Example 1: create db user postgres
sudo -u postgres psql
postgres=
postgres=
postgres=
Example 2: create table in postgresql
CREATE TABLE accounts (
user_id serial PRIMARY KEY,
username VARCHAR ( 50 ) UNIQUE NOT NULL,
password VARCHAR ( 50 ) NOT NULL,
email VARCHAR ( 255 ) UNIQUE NOT NULL,
created_on TIMESTAMP NOT NULL,
last_login TIMESTAMP
);
Example 3: how to create a new user in postgresql
CREATE DATABASE yourdbname;CREATE USER youruser WITH ENCRYPTED PASSWORD 'yourpass';GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;
Example 4: postgres create table
CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
.....
columnN datatype,
PRIMARY KEY( one or more columns )
);