postgres数据库相关使用说明

默认的数据库和用户名是postgres

登录

psql -U postgres -d postgres

ctrl + c (\q) 退出数据库交互模式

创建新用户 gwp

createuser -U postgres -P -d gwp

输入密码
mxq123

使用新用户gwp创建一个数据库gwp

createdb -U gwp gwp

登录新用户和新的数据库

psql -U gwp -d gwp

使用脚本创建表setup.sql

create table posts (

id serial primary key,
content text,
author varchar(255)
);

命令:psql -U gwp -f .\setup.sql gwp

查看表中记录

select * from db;

删除表中记录

delete from db;

猜你喜欢

转载自blog.csdn.net/hust_a/article/details/86528863
今日推荐