Created
October 18, 2017 06:29
-
-
Save TopekoX/38000e2a59022701b8371b187d8db417 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# login root | |
su | |
systemctl start postgresql | |
su - postgres | |
psql | |
# edit password postgres | |
\password postgres | |
# create user & database | |
CREATE USER ucup WITH PASSWORD 'xxxxxx'; | |
CREATE DATABASE office OWNER ucup; | |
# with shell | |
$ createuser ucup | |
$ createdb --owner=ucup office | |
# show databases | |
\l | |
# select database | |
\c office | |
# via command prompt | |
psql -h localhost -p 5432 -U ucup office | |
# drop database | |
DROP DATABASE office | |
# via command prompt | |
dropdb -h localhost -p 5432 -U ucup office | |
# create table | |
CREATE TABLE table_name( | |
column1 datatype, | |
column2 datatype, | |
column3 datatype, | |
..... | |
columnN datatype, | |
PRIMARY KEY( one or more columns ) | |
); | |
# show tables | |
\d | |
\d table_name | |
# drop table | |
DROP TABLE table_name | |
drop table department, company | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment