MySQL 命令总结

数据库命令


  • 查看已有库
    • show databases;
  • 选择库  use <database name>;
  • 查看现在使用的数据库  select database();
  • 显示当前时间,用户名和数据库版本  
    • select now();
    • select user();
    • select version();
  • 创建库  creat database if not exists <database name>;
  • 删除库  drop database if exists <database name>;


表的命令


  • 创建表  create [temporary]  table if not exists 表名 ( 字段与数据类型)
    • 字段名 数据类型 [not null | null] [default default_value] [auto_increment] [unique [key] | [primary] key] [comment 'string']
  • 查看所有的表  show tables;
  • 查看单个表 
    • desc <table name>;
    • describe <table name>;
    • explain <table name>;
  • 修改表
    • rename 命令
      • 移动表的位置  rename table <table name> to <database name.><new table name>;
      • 重命名  rename table <table name> to <new table name>;


数据操作

    • insert 



版权声明:本文为Chandler_river原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。