正则、sqlite
正则表达式主要作用有两方面:
String
.mathces
正则:
\d 数字
\D 非数字
\w 数字、字母、_
.任意字符
? 最多零次或一次
* 任意多的数字
+ 最少一次
Pattern
Matcher
---------------------------------------------------
数据库(内存持久化)sql结构化查询语言
数据库sql主要有以下几种:
Oracle(甲骨文)、DB2、sql Server、MysqL、Access、sqlite
关系型数据库
VS
ASP+Access
PL/sql
T/sql
--------------------------------------
sqlite
D:/android/db/
D:
cd android/db
sqlite3 student.db
.database
以分号;结束
以点.开头的都是命令
-------------------------------------
--创建表student
CREATE TABLE student(
id integer,
name text,
age,integer
);
--向student表中添加一列性别gender
ALTER TABLE student ADD COLUMN gender text;
--插入一条数据--
/*
INSERT INTO 表名(列1,列2,列3)BALUES(值1,值2,值3);
*/
insert into man(id,age,name,gender)values(10000,23,'tom','男');
insert into man(id,'男');
insert into man values(10001,25,'法海','男');
insert into man values(10002,21,'梅鑫','女');
insert into man values(10003,34,'来福','男');
insert into man values(10004,28,'姜文','男');
insert into man values(10005,'李欣','女');
insert into man values(10006,43,'张兰','女');
insert into man values(10007,32,'刘雪','女');
insert into man values(10008,36,'张飞','男');
insert into man values(10009,79,'国老','男');
insert into man values(10010,'关羽','男');
insert into man values(10013,27,'许褚','男');
--修改数据----------------------------
update man set gender='男'where name='梅鑫';
-------------删除数据--------------
delete from man where id=10000;
------------查询-----------------
select * from man;
--select 列名 from 表名 where 条件
select * from man where age>=25;
select * from man where age>=25 and age<=35;
select * from man between 23 and 35;
select * from man where age!=35;
select * from man where age<>25;
--查询所有姓张的学生----模糊查询like
select * from man where name like '%张%';
----------查询前3条数据-----------------
select * from man limit 3;
select * from man limit 3,3;---从第4条开始然后数3条
-----------------------------------------------------
-----查询所有英雄,按照年龄升序(降序desc)排序-------------
select * from man order by age asc;
--------按照年龄降序,年龄相同,则按照id升序排序-----------
select * from man order by age dest,id asc;
------------查询年龄最大的英雄姓名-----------------
select name from man order by age desc limit 1;
---聚合函数 sum() avg() max() min() count()
---求所有的英雄人数
select count(id)"英雄人数" from man;
select count(id) as "英雄人数" from man;
---求所有英雄年龄总和
select sum(age) from man;
select name,min(age) from man;
-----------------------------------------------------------
--------查询男生和女生个数
select gender,count(gender)from student group by gender;
select * from man group by gender;
---查询年龄大于平均年龄的英雄信息 子查询
select * from man where age>(select avg(age) from man);
select avg(age) from man;
---设计国家表 contry
create table contry(
id integer,
name text
);
--给学生表添加一列cid(所在班级的id)
alter table man add column cid integer;
--给班级表添加若干条数据
insert into contry values(10086,'魏国');
insert into contry values(10011,'蜀国');
insert into contry values(10010,'吴国');
--查询英雄姓名和所在国家名称
select man.name 英雄姓名,contry.name 国家姓名 form man,contry where man.cid=contry.cid;
--------------------------
JDBC
Connection数据库连接对象
Statement
PrepareStatement
ResultSet
--------------------------
反射 & 注解//写框架的时候用