使用mysql:
mysql -u root -p
打开对应系统服务 services.msc
1、
查
select row from table;
select * from table;
2、
利用where子句查
select row from table where a(=、<>、>、<、>=、<=、between、like)b;
select row from table where A AND B;
select row from table where A OR B;
select row from table where (A AND B) OR B;
3、对查询结果排序
select row from table order by row; 对row结果排序,默认递增
select row from table order by row desc;递减排序
4、增
insert into table (row1,row3) values('.' , .);
insert into table values('.' , . , .);
5、改
update table set Name='Tom',Address='BeiJing where id=3;
6、删
delete from table where ..;
delete * from table;
7、select * from table LIMIT 5;最多显示5条记录
select TOP 2 * from table;查询前两条记录
select TOP 50 PERCENT * from table;查询50%的记录
8、Where子语句的like模式
select * from where Name like 'j%';以j开头
select * from where Name like '%j';以j结尾
select * from where Name like '%j%';含有j
select * from where Name NOT like 'j%';不含有j
通配符
% 代表若干字符
- 仅代表一个字符
[ ] 字符列中任何单一字符
[!] 不在字符列中的任何单一字符
9、在where子语句中规定多个值
select * from table where name IN ('Mike','Tom');
10、向mysql中导入文本
http://www.cnblogs.com/wingjay/p/3845368.html
新建表格 create table person(id int primary key auto_increment,name varchar(32) not null,age tinyint, address varchar(128));
新建data.txt
因为ID是自增长,可以不输入,只输入后面的信息,tab空格:
zhangsan 30 BeiJing
lisi 23 shanghai
(desc+表名 :可以查看该表的各列名称;s可以查看当前目录)
加载文件:load data local infile "F:/data.txt" into table person(name,age,address); 因为文件中无id信息,故要指明列。