PostgreSQL笔记

基础安装

[code]apt install postgresql

su postgres    #切换到postgres用户

psql    #进入pgsql的CLI

ALTER USER postgres WITH PASSWORD ‘password’;    #更新数据库的postgres用户密码,不是系统的[/code]

监听端口

/etc/postgresql/11/main/postgresql.conf

对listen_addresses和port进行修改

授权远程登陆

/etc/postgresql/11/main/pg_hba.conf

host all all 127.0.0.1/32 md5    #具体说明待补充

自增ID

pgsql需要用到序列(Sequence)

创建序列

[code]CREATE SEQUENCE seq;[/code]

设置字段默认值

[code]SELECT setval(‘seq’, 1);[/code]

查看序列值

[code]SELECT nextval(‘seq’);[/code]

查看所有序列

[code]SELECT * from pg_class WHERE relkind=’S’;[/code]

移除序列

[code]DROP SEQUENCE seq;[/code]

待补充

https://qiita.com/noraworld/items/45d6d987cbc56e157fb1

暂无评论

发送评论 编辑评论


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇