mysql-库基本命令

  • A+
所属分类:数据库 系统

show databases;        #显示库(数据库)列表

    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | phpmyadmin         |
    +--------------------+
    5 rows in set (0.00 sec)

create database db_name;        #创建库

    mysql> create database test;
    Query OK, 1 row affected (0.00 sec)
     
    mysql> show databases;      
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | phpmyadmin         |
    | test               |
    +--------------------+
    6 rows in set (0.00 sec)

drop database db_name;        #删除库

    mysql> drop database test;
    Query OK, 0 rows affected (0.00 sec)
     
    mysql> show databases;    
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | phpmyadmin         |
    +--------------------+
    5 rows in set (0.00 sec)

user db_name;        #选择(进入)指定库;等同于Linux的cd命令;利用命令select database();可查看当前所在库位置

    mysql> use test;
    Database changed
    mysql> select database();
    +------------+
    | database() |
    +------------+
    | test       |
    +------------+
    1 row in set (0.00 sec)
  • 我的微信
  • 欢迎大家,与我交流,非诚勿扰谢谢
  • weinxin
  • 奕知伴解 微信公众号
  • 扫一扫关注,从此不迷路。
  • weinxin
刘銮奕

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: