sqlite數據庫基本操做

1:html:超文本標記語言。裏面有不少標記:主要是作靜態頁面。
 靜態頁面:何時都是不變的。
 動態頁面:不一樣時間訪問是不同的,動態頁面是在靜態頁面的基礎上加了其餘的web開發語言。asp.net,jsp,
2:html的文件都在瀏覽器裏去查看的。瀏覽器才能夠去解析這樣的文件。
3:html文件的後綴是.html或者htm
4:sqlite數據庫:移動系統的數據庫,輕量級數據庫。用戶本身的數據庫就在本身的手機上,因此就沒有什麼數據安全方面的問題。基本上都是單表操做。
 sqlite數據庫中的數據類型;String;字符串,Integer:整數。
null:空的,real:小數。blob:二進制數據。sqlite數據庫中的數據都是由具體的值來肯定的。html

-----------------------------------------------------------------------------------------------------web

 

------建立表結構-
-- sqlite的數據類型:text,integer,real,null,blob,----
----建立表的時候能夠不寫數據類型,數據庫會根據具體值來肯定它的數據類型。------------
create table if not exists student(
       _id integer primary key  autoincrement not null,      
       name string not null,      
       age integer not null,      
       height real,      
       sex string not null ,    
       classname string not null
)
----刪除表------
drop table student
------往表裏面添加數據。 insert into 表名(字段1,字段2) values(值1,值2)--------
------插入一條數據-------
insert into student(name,age,height,sex,classname)
values('小紅',22,162,'女','and1505')
-----插入多條數據-------
insert into student(name,age,sex,height,classname)
 values('李豐',23,'男',180,'and1510'),
 ('小燕',22,'女',159,'and1505')
------查詢表中的數據---------------
-------查詢全部的數據  select-------------
select * from student
------修改數據------
---- update 表名  set 字段 =值-------------
update student set height=163 where _id=7
------班級爲and15010,男,height不爲null,則每一個高度都增加1
update student set height = height+1
where classname='and1510'
 and sex='男'
 and height not null
---------------凡是1510班年齡減1----
update student set age = age-1 where classname='and1510'
-------------凡是1510班或者性別爲女的則高度+1----------------------
update student set height = height+1
where classname='and1510'
or sex='女'
--------修更名字的第一個字爲小的年齡減1歲------------------------
update student set age =age-1
where name like '小%'
---------修更名字爲小謝或者爲小紅的班級爲and1511-----------
update student set classname='and1511'
where name='小王' or name='小謝'
-----------修更名字爲小謝或者爲小紅的班級爲and1510----------------
update student set classname='and1510'
where name in ('小王','小謝')
--------修更名字的第一個字爲小字變成大字---------------
update student set name = replace(name,'小','大')
where name like '小%'
------------刪除數據   delete from 表名 where ---------------------
--------刪除高度爲null的數據-------
delete from student where height is null
select * from student
------刪除全部的數據----------
delete from student
----------刪除名字含有'燕'的記錄-----------------
delete from student where name like '%燕%'
----------刪除高度小於160的記錄------------
delete from student where height<160
-------查詢   select 字段  from 表---------------------
--------查詢性別爲女的-----------------
select * from student where sex='女'
---------查詢全部的---------------
select * from student
-----查詢and1510班的學生的姓名------------
select name from student where classname='and1510'
-------查詢年齡20-25以前的學生-----------------
select * from student where age>=20 and age<=25
-------------查詢名字裏含有大的學生--------------------------------
select * from student where name like '%大%'
---------查詢and1510班女生,而且按年齡從小到大排序-  order by,降序 desc,升序asc,默認就是升序---------------------
select * from student
where  sex='女'
order by age desc
-------------查詢全部女生,而且按年齡從小到大排序-,只顯示前3個----
----limit 偏移量0表示第一個,顯示的個數-----
select * from student
where sex = '女'
order by age
limit 1,3
---查詢出1510班的總人數--------
select count(*) from student where classname='and1510'
------查詢出1510班的全部人的年齡總和---------------
select sum(age) from student
where classname='and1510'
-------查詢出1510班的平均年齡-------------
select avg(age) from student
where classname='and1510'
-----------------查詢全部的班級的男性人數,而且按班級進行分組 group by ---------
select classname,count(*) from student
where sex = '女'
group by classname
-----查詢1510班年齡最大的學員-----------
select max(age),name from student
where classname='and1510'
------查詢1505班年齡最小的學員--------
select min(age) ,name from student
where classname='and1505'
-----查詢班上的全部女學員,按班級進行分組,再進行降序,而且只列出總人數大於等於1個班級-----------
select classname ,count(*)
from student
where sex='女'
group by classname
having count(*)>=1
order by count(*) asc
-------where---group---having---排序 ------------sql

---------------------------------------------------------------數據庫

相關文章
相關標籤/搜索