针对某个用户赋权,一个库表赋予所有权限,其余库表赋予只读权限,应该如何操作?

请先 登录 后评论

1 个回答

Juntao Wang

测试代码如下:

/*
创建三个分布式表:
dfs://test_1/test_1
dfs://test_2/test_2
dfs://test_3/test_3
*/
def createDBAndTable(dbName, tbName) {
	db = database(dbName, VALUE, 0..1)
	model = table(1:0, `id`value, [INT, FLOAT])
	createPartitionedTable(db, model, tbName, `id)
	append!(loadTable(db, tbName), table(rand(1..10, 10000) as id, rand(100.0, 10000) as value))	
}
createDBAndTable("dfs://test_1", "test_1")
createDBAndTable("dfs://test_2", "test_2")
createDBAndTable("dfs://test_3", "test_3")

rpc(getControllerAlias(), createUser{ "test", "123456" }) // 创建测试用户

rpc(getControllerAlias(), grant{ "test", TABLE_READ, ["dfs://test_1/test_1", "dfs://test_2/test_2", "dfs://test_3/test_3"] }) // 所有库表读权限
rpc(getControllerAlias(), grant{ "test", TABLE_WRITE, ["dfs://test_1/test_1"] }) // 一个库表写权限
rpc(getControllerAlias(), grant{ "test", DBOBJ_CREATE, ["dfs://test_1"] }) // 一个库建表权限
rpc(getControllerAlias(), grant{ "test", DBOBJ_DELETE, ["dfs://test_1"] }) // 一个库删表权限
rpc(getControllerAlias(), grant{ "test", DB_OWNER }) // 管理自己创建的数据库

login(`test, `123456)

dropPartition(database("dfs://test_1"), "/1", "test_1")
请先 登录 后评论
  • 1 关注
  • 0 收藏,883 浏览
  • Johhny 提出于 2022-06-11 21:23

相似问题