postgreSQL(SQL语音操作数据库)

操作数据库对象

1. 创建数据库

create database db_yhy with owner = postgres encoding = ‘utf-8’;

2. 数据库修改

alter database db_yhy  rename to db_yihengye;

3. 删除数据库

drop database db_yihengye;

操作数据表对象

1. 创建数据表对象

crate table student(id int, name varchar(30), score numeric(5,2);

2. 修改数据表对象

alter table student rename to student1;

alter table student1 drop column birthday;

3. 删除数据表对象

drop table student1;数据表不存在时会报错

drop table if exists student1; 数据表不存在时会提示不存在,不报错

4. 添加数据库对象字段

alter table student1 add column address varchar(200);

原文地址:https://www.cnblogs.com/yhy-blog/p/15073374.html