-
Notifications
You must be signed in to change notification settings - Fork 19
/
postgreSQL
41 lines (26 loc) · 774 Bytes
/
postgreSQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--creating a database in postgres
CREATE DATABASE "database_name"
WITH
OWNER = postgres
ENCODING = 'UTF8'
CONNECTION LIMIT = -1
IS_TEMPLATE = False;
--creating a table
CREATE TABLE <table_name>
(
column1 int NOT NULL,
column2 varchar(200),
column3 varchar(15),
CONSTRAINT column1_pkey PRIMARY KEY (column1)
)
-- you need to remove '<>'
--inserting data into a table
INSERT INTO table_name(column1, column2, …)
VALUES (value1, value2, …);
---importing data from CSV file
COPY <table_name>(column1,column2,column3,....)
from '<file path\file.csv>'
DELIMITER ','
CSV HEADER
-- you need to remove '<>'
-- remember to match the columns from csv and the table, if you do not map the columns import might give you error.