MySql中的常用命令

一、连接MySql:首先进入MySql的安装目录下的MySql\bin下,再键入mysql -uroot       -proot,这里假定MySql的登陆名为:root,密码为:root。
二、查询当前版本信息:select version();
三、查询当前日期:select current_date;
四、查询服务器中的所有数据库:show databases;
五、使用test库:use test; 此时会提示:Database changed;
六、查询当前所操作的数据库名称:select database();
七、创建一个名称为pubs的新数据库:create database pubs;
八、删除名为pubs的数据库:drop database if exists pubs;
九、创建一个名为student的表:create table student
       (
    stu_Id int parmary key not null,
    stu_Name varchar(20) not null,
    stu_Pass varchar(20) not null,
    stu_Age int not null
       );
十、显示数据库pubs下的所有表:show tables;
十一、查看数据表student的表结构:describe student;
十二、添加记录:insert into student(stu_Id,stu_Name,stu_Pass,stu_Age)     
       values(1,'tom','123',20);
十三、修改记录:update student set stu_Name='jerry' where stu_Id=1;
十四、记录查询:select * from student where stu_Id=2;
十五、删除记录:delete from student where stu_Id=1;
十六、删除表:drop table student;
分享到:

猜你喜欢

转载自liyansheng.iteye.com/blog/1345350