找回密码
 立即注册

推荐阅读

  • 便民服务
  • 关注我们
  • 社区新手
启动mysql服务:service mysqld start
查看mysql服务状态:service mysqld status
重启mysql服务:service mysqld restart
停止mysql服务:service mysqld stop

数据库的操作步骤:
1,进入mysql
2,show databases;==查看当前数据库工具有什么数据库
3,use +库名;==进入数据库
4,create database +新库名;==创建一个新的数据库;
5,create table +新表名(字段名1及类型及约束,字段名2及类型及约束);
==》创建一个新表,包含字段1和字段2
6,desc +表名 ;
==查看表结构
7,show tables;
==》查看当前库有什么表
   *   select datebase();
==》查看当前在哪个库操作
8,alter table test rename test1;
  ==》      修改test为test1
9,alter table test change id sid int(20);
==》修改表test表改变id字段为sid字段int(20)数据类型为   去掉自增长约束                     
10,alter table test change sid sid int(20) auto_increment;
==》修改id字段为sid字段 in(20)int(20),增加自增长约束      
11,alter table test add class int(10);
==》修改表test表增加class字段,数据类型为int(10)增加的字段默认加在表格结构的最后面
12,alter table test add sex varchar(5) first;
==》修改表test表增加sex字段类型为varchar(5) 在表结构的第一位  first为第一位
13,alter table test add age int(10) after sex;
==》修改表test表增加age字段类型为int(10)加在sex字段后面 after  sex
14,alter table test drop sex;
==》修改表test表删除sex字段
15,alter table test drop age,drop class;
==》修改表test表删除age字段和删除class字段
16,alter table test add(class int(10),sex varchar(5));
==》修改表test表增加class和sex字段
17,alter table test modify sex char(5) after name;
==》修改表test表改变sex字段的类型为char (5)以及位置在name字段后面


分享至 : QQ空间
收藏

0 个回复

您需要登录后才可以回帖 登录 | 立即注册