亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

PostgreSQL 序列增刪改案例

 更新時間:2021年01月04日 11:44:15   作者:潘達小新  
這篇文章主要介紹了PostgreSQL 序列增刪改案例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

創(chuàng)建序列

CREATE SEQUENCE if not exists test_mergetable_id_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 999999999
START 1
CACHE 1;
//或者: 
create sequence if not exists test_mergetable_id_seq increment by 1 minvalue 1 no maxvalue start with 1; 

指定序列(給表的主鍵指定創(chuàng)建好的序列)

alter table test_mergetable alter column "i_id" set default nextval('test_mergetable_id_seq');

設置序列自增長從當前最大值開始

SELECT setval('test_mergetable_id_seq', (SELECT MAX(i_id) FROM test_mergetable));
alter sequence test_mergetable_id_seq start with 12;

刪除序列

drop sequence IF EXISTS test_mergetable_id_seq

查看序列

SELECT nextval('test_mergetable_id_seq')

補充:pgsql的schema對用戶授權,單個用戶跨schema增刪改查操作

--創(chuàng)建用戶

create user user1;

--修改密碼

alter user report with password 'password';

--授權查詢權限

grant usage on schema schema1 to user1;
grant usage on schema schema2 to user1;

修改search_path可跨schema操作

set search_path = "$user",user1,user2

--授權schema:schema1給user1權限 這個權限太大需要慎用

grant all on schema schema1 to user1;

--授權schema的表權限給user1 用戶權限太多需慎用

grant all on all tables in schema schema1 to user1;

--授權schema的表權限給user1 用戶權限太多需慎用

grant all on all tables in schema schema1 to user1;

--授權某個schema的單個表查權限

grant select on schema2.table1           to user1;

--收回所有授權

revoke all on all tables in schema schema1 from user1;

--為某個特定用戶設置search_path

alter user user1 set search_path="$user",user1,user2;

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。如有錯誤或未考慮完全的地方,望不吝賜教。

相關文章

最新評論