-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add description about user ATTRIBUTE #11716
Merged
Merged
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6c9aa88
Add description about USER ATTRIBUTE
CbcWestwolf 1fa7aea
Update
CbcWestwolf e0c14d4
Update information-schema/information-schema-user-attributes.md
CbcWestwolf 67ae93c
Apply suggestions from code review
CbcWestwolf 00383ef
Update information-schema/information-schema-user-attributes.md
CbcWestwolf b1047cf
update
CbcWestwolf ad0240e
Apply suggestions from code review
CbcWestwolf d9da2a7
Update example for delete comment
CbcWestwolf 83fbac3
Apply suggestions from code review
CbcWestwolf 9730d36
Update information-schema/information-schema-user-attributes.md
CbcWestwolf 6c97b51
Apply suggestions from code review
CbcWestwolf 2a735b1
Apply suggestions from code review
Oreoxmt 3d51549
Apply suggestions from code review
CbcWestwolf d4ec8bf
Update sql-statements/sql-statement-alter-user.md
CbcWestwolf 8104b78
Apply suggestions from code review
CbcWestwolf d4d51d0
Update
CbcWestwolf cd2032c
make ci happy
Oreoxmt 5d0808d
Remove Mysql compatibility
CbcWestwolf 298c23c
Update information-schema/information-schema-user-attributes.md
CbcWestwolf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: USER_ATTRIBUTES | ||
summary: 了解 INFORMATION_SCHEMA 表 `USER_ATTRIBUTES`。 | ||
--- | ||
|
||
# USER_ATTRIBUTES | ||
|
||
`USER_ATTRIBUTES` 表提供了用户的注释和属性。该表的数据根据 `mysql.user` 系统表生成。 | ||
|
||
{{< copyable "sql" >}} | ||
|
||
```sql | ||
USE information_schema; | ||
DESC user_attributes; | ||
``` | ||
|
||
```sql | ||
+-----------+--------------+------+------+---------+-------+ | ||
| Field | Type | Null | Key | Default | Extra | | ||
+-----------+--------------+------+------+---------+-------+ | ||
| USER | varchar(32) | NO | | NULL | | | ||
| HOST | varchar(255) | NO | | NULL | | | ||
| ATTRIBUTE | longtext | YES | | NULL | | | ||
+-----------+--------------+------+------+---------+-------+ | ||
3 rows in set (0.00 sec) | ||
``` | ||
|
||
CbcWestwolf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{{< copyable "sql" >}} | ||
|
||
```sql | ||
CREATE USER testuser1 COMMENT 'This user is created only for test'; | ||
CREATE USER testuser2 ATTRIBUTE '{"email": "[email protected]"}'; | ||
SELECT * FROM user_attributes; | ||
CbcWestwolf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
```sql | ||
+-----------+------+---------------------------------------------------+ | ||
| USER | HOST | ATTRIBUTE | | ||
+-----------+------+---------------------------------------------------+ | ||
| root | % | NULL | | ||
| testuser1 | % | {"comment": "This user is created only for test"} | | ||
| testuser2 | % | {"email": "[email protected]"} | | ||
+-----------+------+---------------------------------------------------+ | ||
3 rows in set (0.00 sec) | ||
``` | ||
|
||
Oreoxmt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`USER_ATTRIBUTES` 表中列的含义如下: | ||
|
||
* `USER`:用户名。 | ||
* `HOST`:用户的主机名。 | ||
* `ATTRIBUTE`:与当前用户相关的注释和属性。 | ||
CbcWestwolf marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-create-user/','/docs-cn/dev | |
|
||
```ebnf+diagram | ||
CreateUserStmt ::= | ||
'CREATE' 'USER' IfNotExists UserSpecList RequireClauseOpt ConnectionOptions LockOption | ||
'CREATE' 'USER' IfNotExists UserSpecList RequireClauseOpt ConnectionOptions LockOption AttributeOption | ||
|
||
IfNotExists ::= | ||
('IF' 'NOT' 'EXISTS')? | ||
|
@@ -31,6 +31,8 @@ StringName ::= | |
| Identifier | ||
|
||
LockOption ::= ( 'ACCOUNT' 'LOCK' | 'ACCOUNT' 'UNLOCK' )? | ||
|
||
AttributeOption ::= ( 'COMMENT' CommentString | 'ATTRIBUTE' AttributeString )? | ||
``` | ||
|
||
## 示例 | ||
|
@@ -95,6 +97,30 @@ CREATE USER 'newuser5'@'%' ACCOUNT LOCK; | |
Query OK, 1 row affected (0.02 sec) | ||
``` | ||
|
||
创建一个带注释的用户。 | ||
|
||
{{< copyable "sql" >}} | ||
|
||
CbcWestwolf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```sql | ||
CREATE USER 'newuser6'@'%' COMMENT 'This user is created only for test'; | ||
``` | ||
|
||
``` | ||
Query OK, 1 row affected (0.02 sec) | ||
``` | ||
|
||
创建一个具有邮箱 (`email`) 属性的用户。 | ||
|
||
{{< copyable "sql" >}} | ||
|
||
CbcWestwolf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```sql | ||
CREATE USER 'newuser7'@'%' ATTRIBUTE '{"email": "[email protected]"}'; | ||
``` | ||
|
||
``` | ||
Query OK, 1 row affected (0.02 sec) | ||
``` | ||
|
||
## MySQL 兼容性 | ||
|
||
* TiDB 不支持 `WITH MAX_QUERIES_PER_HOUR`、`WITH MAX_UPDATES_PER_HOUR`、`WITH MAX_USER_CONNECTIONS` 等 `CREATE` 选项。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This copy syntax is no longer needed for the current docs website. Please remove it from this doc.