diff --git a/content/zh/post/gaiguoqiang/title/title.png b/content/zh/post/gaiguoqiang/title/title.png new file mode 100644 index 0000000000000000000000000000000000000000..49690dfac611010eccb788b920f2bb58abd8acd0 Binary files /dev/null and b/content/zh/post/gaiguoqiang/title/title.png differ diff --git "a/content/zh/post/gaiguoqiang/\344\273\216Oracle\345\210\260openGauss\345\255\227\345\205\270\350\241\250DBA_TABLES\345\210\260tables\345\257\271\345\272\224.md" "b/content/zh/post/gaiguoqiang/\344\273\216Oracle\345\210\260openGauss\345\255\227\345\205\270\350\241\250DBA_TABLES\345\210\260tables\345\257\271\345\272\224.md" new file mode 100644 index 0000000000000000000000000000000000000000..92c8778ffb6130b1f5e5e28ff363f17ff407162a --- /dev/null +++ "b/content/zh/post/gaiguoqiang/\344\273\216Oracle\345\210\260openGauss\345\255\227\345\205\270\350\241\250DBA_TABLES\345\210\260tables\345\257\271\345\272\224.md" @@ -0,0 +1,120 @@ ++++ + +title = "从Oracle到openGauss:字典表DBA\_TABLES到tables对应" + +date = "2020-11-19" + +tags = ["从Oracle到openGauss:字典表DBA\_TABLES到tables对应"] + +archives = "2020-11" + +author = "盖国强" + +summary = "从Oracle到openGauss:字典表DBA\_TABLES到tables对应" + +img = "/zh/post/gaiguoqiang/title/title.png" + +times = "14:30" + ++++ + +# 从Oracle到openGauss:字典表DBA\_TABLES到tables对应 + +从Oracle数据库向其他数据库过度时,很多朋友会自然而然的寻找属性都过度方式,例如字典表。 + +有人问,类似DBA\_TABLES,DBA\_TAB\_COLUMNS的字典,在openGauss中是否存在呢? + +``` +SELECT OWNER, TABLE_NAME FROM DBA_TABLES; + +SELECT COLUMN_NAME, + DATA_TYPE, + DATA_LENGTH, + COLUMN_ID, + DATA_PRECISION, + DATA_SCALE +FROM DBA_TAB_COLUMNS +``` + +当然会存在对应关系: + +ALL\_TABLES =\> information\_schema.tables + +``` +postgres=> \d information_schema.tables + View "information_schema.tables" + Column | Type | Modifiers +------------------------------+-----------------------------------+----------- + table_catalog | information_schema.sql_identifier | + table_schema | information_schema.sql_identifier | + table_name | information_schema.sql_identifier | + table_type | information_schema.character_data | + self_referencing_column_name | information_schema.sql_identifier | + reference_generation | information_schema.character_data | + user_defined_type_catalog | information_schema.sql_identifier | + user_defined_type_schema | information_schema.sql_identifier | + user_defined_type_name | information_schema.sql_identifier | + is_insertable_into | information_schema.yes_or_no | + is_typed | information_schema.yes_or_no | + commit_action | information_schema.character_data | +``` + +http://www.postgresql.org/docs/current/static/infoschema-tables.html + +ALL\_TAB\_COLUMNS =\> information\_schema.columns + +``` +postgres=> \d information_schema.columns + View "information_schema.columns" + Column | Type | Modifiers +--------------------------+------------------------------------+----------- + table_catalog | information_schema.sql_identifier | + table_schema | information_schema.sql_identifier | + table_name | information_schema.sql_identifier | + column_name | information_schema.sql_identifier | + ordinal_position | information_schema.cardinal_number | + column_default | information_schema.character_data | + is_nullable | information_schema.yes_or_no | + data_type | information_schema.character_data | + character_maximum_length | information_schema.cardinal_number | + character_octet_length | information_schema.cardinal_number | + numeric_precision | information_schema.cardinal_number | + numeric_precision_radix | information_schema.cardinal_number | + numeric_scale | information_schema.cardinal_number | + datetime_precision | information_schema.cardinal_number | + interval_type | information_schema.character_data | + interval_precision | information_schema.cardinal_number | + character_set_catalog | information_schema.sql_identifier | + character_set_schema | information_schema.sql_identifier | + character_set_name | information_schema.sql_identifier | + collation_catalog | information_schema.sql_identifier | + collation_schema | information_schema.sql_identifier | + collation_name | information_schema.sql_identifier | + domain_catalog | information_schema.sql_identifier | + domain_schema | information_schema.sql_identifier | + domain_name | information_schema.sql_identifier | + udt_catalog | information_schema.sql_identifier | + udt_schema | information_schema.sql_identifier | + udt_name | information_schema.sql_identifier | + scope_catalog | information_schema.sql_identifier | + scope_schema | information_schema.sql_identifier | + scope_name | information_schema.sql_identifier | + maximum_cardinality | information_schema.cardinal_number | + dtd_identifier | information_schema.sql_identifier | + is_self_referencing | information_schema.yes_or_no | + is_identity | information_schema.yes_or_no | + identity_generation | information_schema.character_data | + identity_start | information_schema.character_data | + identity_increment | information_schema.character_data | + identity_maximum | information_schema.character_data | + identity_minimum | information_schema.character_data | + identity_cycle | information_schema.yes_or_no | + is_generated | information_schema.character_data | + generation_expression | information_schema.character_data | + is_updatable | information_schema.yes_or_no | +``` + +http://www.postgresql.org/docs/current/static/infoschema-columns.html + +供参考。 + diff --git "a/content/zh/post/gaiguoqiang/\346\226\260\347\224\250\346\210\267\346\235\203\351\231\220\345\222\214permission-denied-for-schema-public.md" "b/content/zh/post/gaiguoqiang/\346\226\260\347\224\250\346\210\267\346\235\203\351\231\220\345\222\214permission-denied-for-schema-public.md" new file mode 100644 index 0000000000000000000000000000000000000000..c9455eace79ac0e0948a25624995cd62c57835bd --- /dev/null +++ "b/content/zh/post/gaiguoqiang/\346\226\260\347\224\250\346\210\267\346\235\203\351\231\220\345\222\214permission-denied-for-schema-public.md" @@ -0,0 +1,119 @@ ++++ + +title = "新用户权限和permission denied for schema public" + +date = "2020-11-19" + +tags = ["新用户权限和permission denied for schema public"] + +archives = "2020-11" + +author = "盖国强" + +summary = "新用户权限和permission denied for schema public" + +img = "/zh/post/gaiguoqiang/title/title.png" + +times = "15:30" + ++++ + +# 新用户权限和permission denied for schema public + +openGauss 安装完成后,会自动创建自定义的帐号,名称默认为omm。默认用户名omm和操作系统用户同名,我们可以通过**REPLACE**修改其密码。 + +``` +omm=# alter role omm identified by 'Open6au55' replace 'Gauss@123'; +NOTICE: The encrypted password contains MD5 ciphertext, which is not secure. +ALTER ROLE +omm=# alter role omm identified by 'Open6au55' replace 'Gauss@123'; +ERROR: The old password is invalid. +``` + +可以使用 omm 登录,创建一个新的用户,我们可以看到 openGauss 对于密码安全的要求: + +``` +omm=# create user enmotech with password 'enmotech'; +ERROR: Password must contain at least three kinds of characters. +omm=# +omm=# create user enmotech with password 'Enm0t3ch'; +NOTICE: The encrypted password contains MD5 ciphertext, which is not secure. +CREATE ROLE +``` + +创建独立的数据库,给用户授权: + +``` +omm=# create database enmotech owner enmotech; +CREATE DATABASE +omm=# GRANT ALL PRIVILEGES ON DATABASE enmotech to enmotech; +GRANT +omm=# ALTER ROLE enmotech CREATEDB; +ALTER ROLE + +omm=# \q +``` + +在操作系统上,连接到容器数据库中: + +``` +[root@ecs-514e-0004 ~]# gsql -d enmotech -U enmotech -W'Enm0t3ch' -h 192.168.1.94 -p 8888 +gsql ((openGauss 1.0 build ec0e781b) compiled at 2020-04-27 17:25:57 commit 2144 last mr 131 ) +Non-SSL connection (SSL connection is recommended when requiring high-security) +Type "help" for help. + +enmotech=> +``` + +注意,此时创建数据表还是遇到错误,不允许在 public 上创建: + +``` +enmotech=> create table yunhe (id number); +ERROR: permission denied for schema public +``` + +类似的建表失败报错可能还累死: + +``` +[Err] ERROR: permission denied for schema public +LINE 1: create table xxxx +``` + +这是因为安全原因,不允许普通客户在public模式下操作。 + +在测试需要下,可以将 ALL PRIVILEGES 授予 enmotech 用户,需要使用超级用户授权,这里是 omm 用户: + +``` +omm=# GRANT ALL PRIVILEGES TO enmotech; +ALTER ROLE +``` + +系统权限又称为用户属性,包括SYSADMIN、CREATEDB、CREATEROLE、AUDITADMIN和LOGIN。 + +``` +omm=# \du + List of roles + Role name | Attributes | Member of +-----------+------------------------------------------------------------------------+----------- + enmotech | Sysadmin | {} + gaussdb | | {} + omm | Sysadmin, Create role, Create DB, Replication, Administer audit, UseFT | {} +``` + +现在 enmotech 这个用户,可以继续测试了: + +``` +eygle=> create table eygle(id number); +CREATE TABLE +eygle=> drop table eygle; +DROP TABLE +``` + +在 openGauss 中,通过 sql 文件,加载数据也非常简单: + +``` +eygle=> \i /tmp/dan.sql +INSERT 0 1 +INSERT 0 1 +... +```