Postgres: วิธี grant permission สำหรับ Database, schemas, tables และ sequences

ก่อนอื่นต้องเป็น user ที่มีสิทธิ์เช้าถึง database และ schema โดยการรัน SQL นี้

SELECT nspname FROM pg_catalog.pg_namespace;

คำสั่งสำหรับ grant database

GRANT ALL PRIVILEGES ON DATABASE yourDBName to yourDBUser;

ALL PRIVILEGES หมายถึง SELECTINSERTUPDATEDELETETRUNCATEREFERENCESTRIGGERCREATECONNECTTEMPORARYEXECUTE, และ USAGE

การจะ Grant table ได้ ต้องระบุ schema ที่ table นั้นๆ อยู่
คำสั่งสำหรับ grant table ในแต่ละ schema

GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA schemaName TO yourDBUser

แล้วหากเรามีหลาย schema ล่ะ ทำไงดี execute ทีล่ะ schema ก็เป็นวิธีหนึ่ง แต่จะง่ายกว่าถ้าเรา loop เพื่อ execute ทีละ schema ซึ่ง postgres สามารถทำได้เลยผ่าน function

DO $do$
DECLARE
    sch text;
BEGIN
    FOR sch IN SELECT schema_name FROM information_schema.schemata
    LOOP
        EXECUTE format($$ GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA %I TO yourDBUser $$, sch);
    END LOOP;
END;
$do$;

References

https://www.postgresql.org/docs/current/ddl-priv.html

KTC & Sephora Join up to Offer Beauty, Cosmetics, and Fashion Exclusively for KTC Card Holders

August 5, 2022 [This is a mock-up draft, but the links are official]

KTC & Sephora Join up to Offer Beauty, Cosmetics, and Fashion Exclusively for KTC Card Holders

Shop for great promotions and discounts at Sephora and Sephora online.

At 12 SEPHORA stores nationwide, the Krungthai Card Public Company (KTC) invites its dear cardmembers and any new KTC card holder to partake in active promotions and discounts.  When a KTC cardmember spends with their KTC credit card between 1 August 2022 – 31 December 2022, that KTC cardholder can redeem a special discount of up to 360 baht.  

If your Sephora total is more than 1,000 THB, you can redeem 1,000 KTC points for a 120 THB discount!   If you’re looking for a complete outfit or cosmetics kit, spending more than 3,000 THB results in a triple discount: 360 THB from your purchase.

For first-time online shoppers, KTC members who shop online with the KTC card at sephora.co.th or on the Sephora mobile app receive access to an additional, promotional 12% discount by entering the code “KTCGIFT12” on the code redemption page.  Not only is there the first-time online shopper discount, but there is also a 10% cash back redemption when a KTC cardmember uses freshly-generated KTC FOREVER points from Sephora online purchases.  

With less than 150 days until the end of the promotion on December 31st, 2022 , don’t miss out on your chance to redeem 10X KTC FOREVER points from EVERY online Sephora transaction.  

More information on registration and participation on the KTC & Sephora exclusive cardmember promotion can be found at

https://www.ktc.co.th/promotion/online/shopping/shoponline

Any potentially new cardmember interested parties may call for more information on our KTC hotline:

02 123 5000,

or

apply in person for a KTC credit card at any one of our KTC Touch branches throughout Thailand,

or

simply register online here.


Krungthai Corporate Communication Relations Public Company Limited

Khun Kantharat Jermchitphong & Khun Paradee TesratanawongPh: (02) 828-5049 | Email: ktc_pr@ktc.co.th