IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

五、MySQL 日常管理

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

文章永久连接:https://tech.souyunku.com/?p=4867

下面列出了日常管理 MySQL 数据库过程中常用的命令

USE 命令

USE 命令用于选择要操作的 MySQL 数据库

使用该命令后所有 MySQL 命令都只针对该数据库

USE 命令语法格式如下

USE **数据库名** 

示例

MariaDB [(none)]> USE test;
Database changed
MariaDB [test]>

可以看到,使用了 USE 命令后, mysql 提示符中的 [(none)] 会变成 [test]

SHOW DATABASE 命令

SHOW DATABASES 命令用于列出 MySQL 数据库管理系统的数据库

MariaDB [test]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

SHOW TABLES 命令

SHOW TABLES 命令用于列出指定数据库中的所有表 使用该命令前需要使用 USE 命令来选择要操作的数据库

MariaDB [test]> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> SHOW TABLES;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)

SHOW COLUMNS FROM 命令

SHOW COLUMNS FROM table_name 命令用于显示数据表的属性,属性类型,主键信息 ,是否为 NULL,默认值等等信息

MariaDB [test]> SHOW COLUMNS FROM comps;
+---------+--------------+------+-----+---------+----------------+
| Field   | Type         | Null | Key | Default | Extra          |
+---------+--------------+------+-----+---------+----------------+
| id      | int(11)      | NO   | PRI | NULL    | auto_increment |
| name    | varchar(64)  | YES  |     | NULL    |                |
| website | varchar(128) | YES  |     | NULL    |                |
| city    | varchar(32)  | YES  |     | NULL    |                |
| ceo     | varchar(32)  | YES  |     | NULL    |                |
+---------+--------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)

SHOW INDEX FROM 命令

SHOW INDEX FROM table_name 命令用于显示数据表的详细索引信息,包括 PRIMARY KEY(主键)

MariaDB [test]> SHOW INDEX FROM comps\G
*************************** 1. row ***************************
        Table: comps
   Non_unique: 0
     Key_name: PRIMARY
 Seq_in_index: 1
  Column_name: id
    Collation: A
  Cardinality: 2
     Sub_part: NULL
       Packed: NULL
         Null:
   Index_type: BTREE
      Comment:
Index_comment:
1 row in set (0.00 sec)

SHOW TABLE STATUS LIKE LIKE 命令

SHOW TABLE STATUS LIKE [FROM db_name] [LIKE ‘pattern’] 命令用于输出 MySQL 数据库管理系统的性能及统计信息

1. 显示数据库 test 中所有表的信息

MariaDB [(none)]>  SHOW TABLE STATUS  FROM test\G
*************************** 1. row ***************************
           Name: comps
         Engine: InnoDB
        Version: 10
     Row_format: Compact
           Rows: 5
 Avg_row_length: 3276
    Data_length: 16384
Max_data_length: 0
   Index_length: 0
      Data_free: 10485760
 Auto_increment: 8
    Create_time: 2017-10-08 19:13:22
    Update_time: NULL
     Check_time: NULL
      Collation: utf8mb4_unicode_ci
       Checksum: NULL
 Create_options:
        Comment:
1 row in set (0.00 sec)

显示表名以 comps 开头的表的信息

MariaDB [test]> SHOW TABLE STATUS FROM test LIKE '%comps%'\G
*************************** 1. row ***************************
           Name: comps
         Engine: InnoDB
        Version: 10
     Row_format: Compact
           Rows: 5
 Avg_row_length: 3276
    Data_length: 16384
Max_data_length: 0
   Index_length: 0
      Data_free: 10485760
 Auto_increment: 8
    Create_time: 2017-10-08 19:13:22
    Update_time: NULL
     Check_time: NULL
      Collation: utf8mb4_unicode_ci
       Checksum: NULL
 Create_options:
        Comment:
1 row in set (0.00 sec)

干货推荐

本站推荐:精选优质专栏

附录:MySQL 教程:系列文章


Warning: A non-numeric value encountered in /data/wangzhan/tech.souyunku.com.wp/wp-content/themes/dux/functions-theme.php on line 1154
赞(83) 打赏



未经允许不得转载:搜云库技术团队 » 五、MySQL 日常管理

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码
IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

评论 抢沙发

大前端WP主题 更专业 更方便

联系我们联系我们

觉得文章有用就打赏一下文章作者

微信扫一扫打赏

微信扫一扫打赏


Fatal error: Uncaught Exception: Cache directory not writable. Comet Cache needs this directory please: `/data/wangzhan/tech.souyunku.com.wp/wp-content/cache/comet-cache/cache/https/tech-souyunku-com/index.q`. Set permissions to `755` or higher; `777` might be needed in some cases. in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php:367 Stack trace: #0 [internal function]: WebSharks\CometCache\Classes\AdvancedCache->outputBufferCallbackHandler() #1 /data/wangzhan/tech.souyunku.com.wp/wp-includes/functions.php(5109): ob_end_flush() #2 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(303): wp_ob_end_flush_all() #3 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters() #4 /data/wangzhan/tech.souyunku.com.wp/wp-includes/plugin.php(470): WP_Hook->do_action() #5 /data/wangzhan/tech.souyunku.com.wp/wp-includes/load.php(1097): do_action() #6 [internal function]: shutdown_action_hook() #7 {main} thrown in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php on line 367