Search
 
SCRIPT & CODE EXAMPLE
 

SQL

create table in postgresql

 -- Example table
 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 
);
Comment

postgre sql create table

CREATE TABLE cities (
    city_id serial PRIMARY KEY,
    city_name VARCHAR (255) NOT NULL,
    population INT NOT NULL CHECK (population >= 0)
);

Comment

postgresql create table as select

CREATE TABLE films_recent AS
  SELECT * FROM films WHERE date_prod >= '2002-01-01';
Comment

create table postgresql

CREATE TABLE table_name (
	column_name TYPE column_constraint,
	table_constraint table_constraint
) INHERITS existing_table_name;
Comment

Create postgres table

CREATE TABLE holiday_calender (
	hcl_id bigserial NOT NULL,
	hcl_country integer,
	hcl_company integer,
	hcl_date timestamp NULL,
	hcl_description varchar(500) NULL,	
	hcl_active int4 NOT NULL,
	CONSTRAINT holiday_calender_pkey PRIMARY KEY (hcl_id)
);
Comment

show create table in postgresql

pg_dump -t 'schema-name.table-name' --schema-only database-name
Comment

create table database in psql

virtual_pets=# CREATE TABLE communities (id SERIAL PRIMARY KEY, name varchar, description varchar);
CREATE TABLE
Comment

PREVIOUS NEXT
Code Example
Sql :: what is denormalization in sql 
Sql :: mysql generate create table script 
Sql :: min mysql 
Sql :: count sql 
Sql :: partition-by 
Sql :: 2 max value in sql 
Sql :: what data type to use for phone number in sql 
Sql :: sql vs nosql 
Sql :: insert or update sql query 
Sql :: mysql pad zeros 
Sql :: connect by query in oracle 
Sql :: TRIGGER AFTER 
Sql :: last 2 mins sql server 
Sql :: view acl table oracle 
Sql :: copy data from one postgres container to another 
Sql :: mysql autoincrement valor inicial 
Sql :: reset counter postgres 
Sql :: mariadb search columns 
Sql :: MySql Subtract a table from another 
Sql :: xml to column sql 
Sql :: sql alias 
Sql :: insert or update cassandra 
Sql :: update multiple rows 
Sql :: oracle sql get value from several rows and concatenate strings 
Sql :: sql creating tables 
Sql :: postgres advance table id count 
Sql :: sql select maximum column with other columns returned 
Sql :: sql server get number of working days in a month 
Sql :: tables in sql 
Sql :: incorrect datetime value sql table error 1292 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =