msql数据库常用指令操作
数据库指令
1.数据库指令
创建数据库:create database db_name;
删除数据库:drop database db_name;
显示数据库:show databases;
导出数据库:mysqldump -uroot -P3306 -p db_name> f:\db_name.sql
导入数据库:source f:/db_name.sql;
2.数据表指令
创建数据表:create table tb_name;
删除数据表:drop table tb_name;
清空数据表:delete from tb_name;
显示数据表:show tables;
数据库间表操作:create table tb1_name select * from tb2_name;
不同数据库之间表操作:INSERT INTO tb_name select * from db_name.tb_name where id LIKE 'condition';
3.增删改查
Insert:insert into tb_name (field1,field5...fieldx) values (value1,value2...valuex);
Delete:delete from tb_name [where condition];
Update:update tb_name set field1=value1,field2=value2 [where condition];
Select:select * from tb_name [where condition];
4.其他语句
like子句:select * from tb_name where field1 like 'value_';
select * from tb_name where field1 like 'value%';
replace:update tb_name set fieldX=replace(fieldX,string,mystring);