Mysql数据库----基本的sql命令

1.SQL命令的使用规则

  • 每条命令必须以;结尾
  • sql命令不区分字母大小写
  • 使用\c来终止当前命令执行

2.库的管理

1)库名的命名规则

  • 数字、字母、下划线,但不能使用纯数字
  • 库名区分字母大小写
  • 不能使用特殊字符和mysql字符

2)库的基本操作

    ①查看已有的库     show databases ;
    ②创建库(指定字符集)    create database 库名[character set utf8] ; 
    ③查看创建库得语句(字符集)   show create database 库名 ;
    ④查看当前所在库     select database() ;
    ⑤切换库   use 库名;
    ⑥查看库中已有表   show tables; 
    ⑦删除库   drop database 库名;

3.表的管理

1)表的命名规则(与库的命名规则一样)

  • 数字、字母、下划线,但不能使用纯数字
  • 库名区分字母大小写
  • 不能使用特殊字符和mysql字符

2)表的基本操作

       1.创建表(指定字符集)
          create table 表名(字段名 数据类型,字段名 数据类型...);
       2.查看已有表的字符集
          show create table 表名;
       3.查看表结构
          desc 表名 ;
       4.删除表
           drop table 表名; 

猜你喜欢

转载自blog.csdn.net/py_1995/article/details/84142353