常用操作
# 命令行连接数据库
psql -h localhost -p 5432 -U postgres runoobdb
\l # 查看数据库
\c DBNAME # 进入数据库
\d # 查看表
# 创建数据库
CREATE DATABASE dbname;
# 删除数据库
DROP DATABASE [ IF EXISTS ] name
# 创建表
CREATE TABLE COMPANY(
ID INT PRIMARY KEY NOT NULL,
NAME TEXT NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR(50),
SALARY REAL
);
# 删除表
DROP TABLE table_name;
# 插入数据
INSERT INTO TABLE_NAME (column1, column2, column3,...columnN)
VALUES (value1, value2, value3,...valueN);
# 查询数据
SELECT column1, column2,...columnN FROM table_name;
标签:...,常用,postgres,数据库,TABLE,操作,NULL,name
From: https://www.cnblogs.com/lazysang/p/17251823.html