一、mysql>show databases;---------查询所有数据库
二、mysql>use 库名(mydb);-----------------选择你所创建的数据库
三、mysql>show tables;--------------查询所在数据库所有表
mysql>fludh mydb;---------------刷新数据库
mysql>desc 表名(student)------------显示表结构
\. 文本地址\bbs.sql回车---------例:\. D:\java\bbs.sql回车
四、创建一个数据库:
mysql> create database mydb;
五、创建一个表:
mysql>create table student(stu_id int primary key主键,stu_no varchar(20),stu_name varchar(50),stu_phone varchar(15));
mysql>create table class(cls_id int,cls_no varchar(20),cls_name varchar(50),cls_stuid int forign key外键);
五、增删查改命令:
添加一条记录:mysql>insert into mydb values(1,’小明’,’学生’);
删除一条记录:mysql>delete from 表名(student) where id=1;
mysql>delete from student;(清空表)
删除一张表:mysql>drop table student;
查询数据 :mysql> select * from hkw12_class;
更改一条数据:update student set name=’小明’ where name=’龙悦’;
六、重命名表:mysql>alter table t1 rename t2;
七、退出:quit或者exit(回车)
八、查询字符编码:show variables like‘character%’;
九、更改字符编码:set names ‘utf8’;
十、停止服务:”运行”-----cmd------net stop mysql(回车)
十一、开启服务:”运行”-----cmd------net start mysql(回车)
十二、自增
十三、Mysql获取当前时间 mysql>select now()
十四、将当前时间转换成字符串 mysql>select dataformat(now(),'%y-%m-%d %h:%i:%s')
十五 分页:select * FROM student LIMIT 1,2(第一个参数为起始索引(页码-1)*页面大小,第二个参数为页面大小 )