•   欢迎来到21NN网.
  •   请记住本站网址www.21nn.cn

GreenPlum中一样平常SQL剧本【MySQL教程】,GreenPlum,脚本,日常

摘要: --1.指定月份统共若干天SELECTEXTRACT(DAYFROMCAST('2017-08-01'ASDATE)+INTERVAL'1month'-INTERVAL...
--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剧本的细致内容,更多请关注ki4网别的相干文章!

分享到:

发表评论

评论列表

还没有评论,快来说点什么吧~

公众号二维码

微信公众号