MySQLでユーザーのすべての許可を表示する
INFORMATION_SCHEMA.SCHEMA_PRIVILEGESを使用して、ユーザーのすべての許可を表示します-
select *from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES;
上記の構文を実装して、ユーザーのすべての許可を表示しましょう-
mysql> select *from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES;
これにより、次の出力が生成されます-
+-----------------------------+---------------+--------------------+-------------------------+--------------+ | GRANTEE | TABLE_CATALOG | TABLE_SCHEMA | PRIVILEGE_TYPE | IS_GRANTABLE | +-----------------------------+---------------+--------------------+-------------------------+--------------+ | 'mysql.sys'@'localhost' | def | sys | TRIGGER | NO | | 'Adam Smith'@'localhost' | def | test | SELECT | NO | | 'Adam Smith'@'localhost' | def | test | INSERT | NO | | 'Adam Smith'@'localhost' | def | test | UPDATE | NO | | 'Adam Smith'@'localhost' | def | test | DELETE | NO | | 'Adam Smith'@'localhost' | def | test | CREATE | NO | | 'Adam Smith'@'localhost' | def | test | DROP | NO | | 'Adam Smith'@'localhost' | def | test | REFERENCES | NO | | 'Adam Smith'@'localhost' | def | test | INDEX | NO | | 'Adam Smith'@'localhost' | def | test | ALTER | NO | | 'Adam Smith'@'localhost' | def | test | CREATE TEMPORARY TABLES | NO | | 'Adam Smith'@'localhost' | def | test | LOCK TABLES | NO | | 'Adam Smith'@'localhost' | def | test | EXECUTE | NO | | 'Adam Smith'@'localhost' | def | test | CREATE VIEW | NO | | 'Adam Smith'@'localhost' | def | test | SHOW VIEW | NO | | 'Adam Smith'@'localhost' | def | test | CREATE ROUTINE | NO | | 'Adam Smith'@'localhost' | def | test | ALTER ROUTINE | NO | | 'Adam Smith'@'localhost' | def | test | EVENT | NO | | 'Adam Smith'@'localhost' | def | test | TRIGGER | NO | | 'David'@'localhost' | def | test | SELECT | NO | | 'David'@'localhost' | def | test | INSERT | NO | | 'David'@'localhost' | def | test | UPDATE | NO | | 'David'@'localhost' | def | test | DELETE | NO | | 'David'@'localhost' | def | test | CREATE | NO | | 'David'@'localhost' | def | test | REFERENCES | NO | | 'David'@'localhost' | def | test | ALTER | NO | | 'mysql.session'@'localhost' | def | performance_schema | SELECT | NO | | 'Robert'@'%' | def | sample | SELECT | YES | | 'Robert'@'%' | def | sample | INSERT | YES | | 'Robert'@'%' | def | sample | UPDATE | YES | | 'Robert'@'%' | def | sample | DELETE | YES | | 'Robert'@'%' | def | sample | CREATE | YES | | 'Robert'@'%' | def | sample | DROP | YES | | 'Robert'@'%' | def | sample | REFERENCES | YES | | 'Robert'@'%' | def | sample | INDEX | YES | | 'Robert'@'%' | def | sample | ALTER | YES | | 'Robert'@'%' | def | sample | CREATE TEMPORARY TABLES | YES | | 'Robert'@'%' | def | sample | LOCK TABLES | YES | | 'Robert'@'%' | def | sample | EXECUTE | YES | | 'Robert'@'%' | def | sample | CREATE VIEW | YES | | 'Robert'@'%' | def | sample | SHOW VIEW | YES | | 'Robert'@'%' | def | sample | CREATE ROUTINE | YES | | 'Robert'@'%' | def | sample | ALTER ROUTINE | YES | | 'Robert'@'%' | def | sample | EVENT | YES | | 'Robert'@'%' | def | sample | TRIGGER | YES | | 'Robert'@'%' | def | web | EXECUTE | NO | +-----------------------------+---------------+--------------------+-------------------------+--------------+ 46 rows in set (0.00 sec)
-
MySQLでテーブルのすべてのフィールドを表示しますか?
すべてのフィールドを表示するには、以下の構文のように、データベースをtable_schemaで設定し、特定のテーブルをtable_nameで設定します- select column_name as anyAliasName from information_schema.columns where table_schema=database() and table_name=’yourTableName’\G まずテーブルを作成しましょう- mysql> create table DemoTable1938 &
-
MySQLのNULL値の場合は1を表示します
まずテーブルを作成しましょう- mysql> create table DemoTable1963 ( Counter int ); Query OK, 0 rows affected (0.00 sec) 挿入コマンド-を使用して、テーブルにいくつかのレコードを挿入します mysql> insert into DemoTable1963 values(20); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1963