insert into tablexxxxx (column_list) VALUES (value_list);
Create table person
(
id INT Unsigned not null auto_increment,
name char(40) not null Default '',
age int not null default 0,
info char(50) null,
primary key(id)
);
insert into person(id,name,age,info)
-> values
-> (1,'zdb',20,'Student');
update tablename
set column_name1 = valu1, column_name2 = valu2,...,column_namen = valun
where (condition);
update person SET age = 15,name ='LiHua' where id=10;
delete from tablename where....
select f_id, f_name from tableX where f_name LIKE 'b%'
%可用来匹配字符串
'%g%'
orange mango 都会匹配到
_只能匹配一个字符
select f_id, f_name from tableX where f_name LIKE 'b_____'
banana这样子的
select f_id, f_name from tableX where f_price is NULL
select f_id, f_name from tableX where f_price is between XXX AND XXX
select f_id, f_name from tableX where (A) AND (B)
select f_id, f_name from tableX where (A) OR (B)
select f_id, f_name from tableX where (A) AND (B) ORDER BY f_name;
按f_name排序
select f_id, f_name from tableX where (A) AND (B) ORDER BY f_name,f_price;
先按照f_name,再按照f_price
select f_id, f_name from tableX where (A) AND (B) ORDER BY f_price DESC;
降序
select f_id, f_name from tableX where (A) AND (B) ORDER BY f_price DESC,f_name;
price降序,name oridinary排序
mysqldump -u root -p Learning_2_Data > /home/db-zhang/hello_world.sql;
mysqldump -u root -p --all-databases > /home/db-zhang/hello_world.sql;
mysqldump -u root -p databases Learning_2_Data,XXXXX > /home/db-zhang/hello_world.sql;
mysqlhotcopy -u root -p Learning_2_Data /home/db-zhang/backup;
以上是储存数据库
以下是数据库打回复
mysqldump -u root -p Learning_2_Data < /home/db-zhang/hello_world.sql;
mysql> use Learning_2_Data
mysql> source /home/db-zhang/hello_world.sql
chown -R /home/db-zhang/hello_world.sql var/lib/mysql/dbname
cp -R /home/db-zhang/backup/test /home/db-zhang/mysql/data