早打算寫些關于資料庫操作方面的知識了,現在終于完成了第一篇,以下記錄了關于mysql操作方面的基礎知識。
在window下,啟動、停止mysql服務
啟動mysql資料庫
net start mysql
停止mysql資料庫
net stop mysql
重新啟動mysql資料庫
net restart mysql
指令行形式,mysql基本指令的使用
1、指令的取消
\c
2、退出mysql視窗
exit;或quit;或ctrl+c
3、檢視資料庫版本号
select version();
4、顯示目前存在的資料庫
show databases;
5、選擇test資料庫
use test;
6、檢視選擇的資料庫
select database();
7、設定資料庫中文編碼
set names utf8;
8、建立一個test資料庫
create database test
9、建立一張mtest表
create table mtest(
id tinyint(2) unsigned not null auto_increment,
name varchar(20),
sex char(1),
email varchar(50),
birth datetime,
primary key (id)
);
10、向mtest表中插入一條資料
insert into mtest(`name`,`sex`,`email`,`birth`) values ('zhangsan','1','[email protected]',now());
11、查詢mtest表中name為張三的資訊
select * from mtest where name='zhangsan';
12、按照id号降序輸出
select * from mtest order by id desc;
13、顯示第11至20條資料資訊
select * from mtest id limit 10,10;