MySql的一些基本使用及操作命令 (待更新)

一,至于怎样安装配置mysql,网上有很多教程。。。。。。。。。。

二,  登录到mysql服务器上:

    mysql -uroot -p

    紧接着输入密码就可以了。

三,  my sql 命令的使用:以分号或\g结束,\c取消一行命令,\h帮助

    1、 显示数据库:show databases;

    2、 建数据库:create database  [if not exists] 数据库名;

    3、 建数据表: create table [if not exists] 表名 (字段名1   类型。。。。。。。。)

      eg:   create table student (编号 int auto_increment primary key, 姓名 varchar(10));

          注意:设置了 auto_increment 自动增长,就要定为主键,如果选择了BIT 类型,0不显示,非0显示为一个特殊符号!

    4、 显示数据表:show tables;

    5、 删除库: drop database [if exists] 库名;

    6、 删除表: drop table   [if exists] 表名;

    7、 显示表结构: desc 表名

    8、 如何修改表结构:

          删除一个字段:   alter table  表名 drop 字段名

          修改一个字段的属性:    alter table 表名 modify 字段 新属性

          修改主键:

               增加一个主键  alter table 表名 add primary key(字段名)

               删除一个主键  alter table 表名  drop primary key(字段名)

               (删除自增长的主键id :先删除自增长在删除主键
                        Alter table tb change id id int(10);              //删除自增长
                        Alter table tb drop primary key;                  //删除主建

               )

四, 

原文地址:https://www.cnblogs.com/jackge/p/3130655.html