參考教程:http://www.yiibai.com/mysql/install-mysql.html#
1.創(chuàng)建庫(不存在則創(chuàng)建万栅,存在則不創(chuàng)建)
CREATE DATABASE IF NOT EXISTS JIANSHU DEFAULT CHAREST utf8 COLLATE utf8_general_ci
2.選擇數(shù)據(jù)庫
use JIANSHU
3.創(chuàng)建數(shù)據(jù)表
Create table if not exists ' jianshuarticle ' (?
'_id' int unsigned auto_increment,
'_title' varchar(100) not null,
'_author' varchar(40) not null,
'submisson_date' DATE,
primary key ('_id')
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
4.增加數(shù)據(jù)
insert into jianshuarticle ('_title','_author','submisson_date') values ('MySQL的簡單使用方法','mister','2017-12-20')
5.刪除數(shù)據(jù)
delete from jianshuarticle?
where _id=1
6.修改數(shù)據(jù)
update jianshuarticle
set
? ? ?submisson_date='2017-12-21'
where?
? ? ? name='MySQL的簡單使用方法'
7.查詢數(shù)據(jù)
select ?_id,_title,_author?
from jianshuarticle
where _id=1?
limit 10;