--1. Specify the total number of days in the month
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. Modify the default search (search_path) path
SHOW search_path; SET search_path TO your_schema_name;
--3.Change the schema owner
ALTER SCHEMA your_schema_name OWNER TO other_user;
--4.Modify the table owner
ALTER TABLE your_table_name OWNER TO other_user;
--5. Grant query or all permissions to the specified user
GRANT SELECT ON TABLE your_table_name TO other_user; GRANT ALL ON TABLE your_table_name TO other_user;
--6. Grant the specified user Schema usage permissions
GRANT USAGE ON SCHEMA your_schema_name TO other_user;
--7. Recycle the specified user’s schema usage permissions
REVOKE ALL ON SCHEMA your_schema_name FROM other_user;
--Different object authorization keywords
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. Grant function execution permissions in batches
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
The above is the detailed content of Daily SQL scripts in GreenPlum. For more information, please follow other related articles on the PHP Chinese website!