命令行操作MySQL的一些简单命令

启动MySQL                       net start mysql    
停止MySQL                       net stop mysql  

进入MySQL安装目录        c:\wamp\bin\mysql\mysql5.6.17\bin\ 

进入MySQL                        mysql.exe -h localhost -u root -p 


退出MySQL                       exit; 

查看已创建的数据库        show databases; 
创建数据库                        create database fly_test character set gbk; 
指定使用的数据库            use fly_test; 
创建表                                create table students(id int not null auto_increment,name varchar(12),age int,sex varchar(4),primary key (id) );

查看表                                show tables; 
查看表的详细信息            describe students; 

插入数据                            insert into students values(  "白鸽", "男", 20, "18888888888" ); 
                                            insert into students(name, sex, age)values("龙颜", "男", 10);

查询                                    select name, age from students;
                                            select * from students;
条件查询                            select * from students where age > 12; 
                                            select * from students where name like "%白";
                                            select * from students where id < 5 and age > 2;
排序                                    select * from students order by age [desc];

更新                                    update students set tel = default where id = 1; 
                                            update students set age = age + 1;
                                            update students set name = "baige", sex = "nan" where age = 21;

删除                                    delete from students where id =3; 
删空表                                delete from students; 

添加列                                alter table students add address char(60); 
                                            alter table students add birthday date after age;
                                            alter table students change tel telphone char(13) default "-";
                                            alter table students change name name char(16) not null;
删除列                                alter table students drop birthday;

重命名表                            alter table students rename workmates; 
删除整张表                        drop table 表名;
删除数据库                        drop database 数据库名; 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值