--1.指定月份總共多少天
SELECT EXTRACT(DAY FROM CAST('2017-08-01' AS DATE) + INTERVAL '1 month' - INTERVAL '1 day') SELECT EXTRACT(DAY FROM CAST(TO_CHAR(NOW(),'YYYY-MM')||'-01' AS DATE) + INTERVAL '1 month' - INTERVAL '1 day')
--2.修改預設搜尋(search_path)路徑
SHOW search_path; SET search_path TO your_schema_name;
--3.更改schema擁有者
ALTER SCHEMA your_schema_name OWNER TO other_user;
--4.修改表的擁有者
ALTER TABLE your_table_name OWNER TO other_user;
--5.授予指定使用者查詢或所有權限
GRANT SELECT ON TABLE your_table_name TO other_user; GRANT ALL ON TABLE your_table_name TO other_user;
#--6.授予指定用戶schema使用權限
GRANT USAGE ON SCHEMA your_schema_name TO other_user;
--7.回收指定使用者schema使用權限
REVOKE ALL ON SCHEMA your_schema_name FROM other_user;
--不同物件授權關鍵字
TABLES,VIEWS,SEQUENCES: SELECT INSERT UPDATE DELETE RULE ALL EXTERNAL TABLES: SELECT RULE ALL DATABASES: CONNECT CREATE TEMPORARY|TEMP ALL FUNCTIONS: EXECUTE PROCEDURAL LANGUAGES: USAGE SCHEMAS: CREATE USAGE ALL
--8.批次授予函數執行權限
SELECT 'GRANT EXECUTE ON FUNCTION '||routines.routine_name||'('||STRING_AGG(parameters.data_type,',' ORDER BY parameters.ordinal_position)||') TO other_user;' batchgrant FROM information_schema.routines JOIN information_schema.parameters ON routines.specific_name=parameters.specific_name WHERE routines.specific_schema='product' GROUP BY routines.routine_name
以上是GreenPlum中日常SQL腳本的詳細內容。更多資訊請關注PHP中文網其他相關文章!