基本操作
登陆
psql -h 服务器 -U 用户名 -d 数据库 -p 端口 //-U是大写
数据库操作
create database 数据库名 with owner = 所有者 encoding = 编码格式;
create database mydb with owner = postgres encoding = 'utf-8';
alter database mydb rename to mydb2;
alter database mydb connection limit 20;
drop database mydb;
\l、\c、\q
数据表操作
create table student(
id serial primary key,
name varchar(255)
);
alter table student rename to student1;
alter table student rename id to numberID;
alter table student alter column name type varchar(40);
alter table student drop column name;
alter table student add column good varchar(200);
drop table student;
drop table if exists student;
\d、\d student