테이블의 CRUD
4164 단어 데이터베이스
(Create)、 (Retrieve)、 (Update)、 (Delete)
--------------- --------------
. insert into
insert into ta_name[ , ] values( ),...
. update
update set = ,...
[where ]
[limit]
create table tt20(
id int comment ' ',
name varchar(10) not null
);
insert into tt20 values(1,'lisi'),(2,'wang'),(3,'mr.S');
update tt20 set id= 4; #
update tt20 set id=5 where name = 'lisi';# name lisi id=5;
update tt20 set id=4 limit 1;#
. delete
delete from
[where ] # where ,
truncate table # 0;
.
select * 。
1.select [distinct( )] * | ( ) from ;
create table student(
id int(2) zerofill primary key auto_increment comment ' , 100 ',
name varchar(10),
chinese decimal(4,1) default 0.0 not null,
english decimal(4,1) default 0.0 not null,
math decimal(4,1) default 0.0 not null
);
insert into student values
(1,'lisi',89.0,78.0,90.0),
(2,'tang',67.0,98.0,56.0),
(3,'sun',87.0,78.0,77.0)
;
insert into student(name,chinese,english,math) values
('lao',88.0,98.0,90.0),
('hong',82.0,84.0,67.0)
;
insert into student values
(6,'ru',55.0,85.0,45.0),
(7,' ',75.0,65.0,30.0)
;
select id,name,chinese from student;
select distinct math from student; #
select chinese+english+math from student;#
2.as
select chinese+english+math as ' ' from student; # as
3.where (and or)
tang 60%
select name,(chinese+english+math)*1.6
from student
where name like 'tang%';#like
90
select name,english from student
where english > 90;
li >85
select name,(chinese+english+math) from student
where name like 'li%' and math > 85;
200
select id,name from student
where (chinese+math+english)>200 and
math < chinese and
name like 'tang';
84-90
select id,name from student
where engish>=84 and english <=90;
4.between and
select id,name from student
where english between 84 and 90;# between..and..
200
select name,(english+chinese+math) as total from student
where total >200; # where
5.order by
select [distinct( )] ...
from
[where ]
order by asc( ) | desc;
200 ,
select name,(english+chinese+math) as total from student
where (english+chinese+math) >200
order by total;
6.
select...
[where ]
limit ,
, 3 , 。
select * from student limit 3,3; # 4,5,6
7.
count( |*) null
sum()
avg()
max()
min()
select count(math) from student; #7
select count(*) from student; #7
alter table student modify math decimal(4,1) default 0.0;
insert into student values(8,'opo',89,99,null);
select count(math) from student; #7
select count(*) from student; #8
8. group by
having
select ..
from
group by
select avg( ),max( )
from
group by ;
select avg(sal),max(sal),deptno
from emp
group by deptno;
2000
select avg(sal) as avg_sal,deptno
from emp
group by deptno having avg_sal <2000;
-------------------- ----------------
,
(1,2)(3,4) = [(1,3),(1,4),(2,3),(2,4)]
select ename,sal,dname
from emp,dept
where emp.deptno = dept.deptno;#
10 ,
select dname,ename,sal
from emp,dept
where emp.deptno = dept.deptno
and emp.deptno = 10;# deptno
------------------- ---------------
SMITH ,
select ename,empno
from emp
where empno=(select deptno
from emp
where ename = 'SMITH');# SMITH
select deptno
from emp
where ename = 'SMITH';
------------------- ----------------
:
create index empno_index on emp(empno); # emp empno empno_index
:
1.
2.
3.
4. where
------------------- -----------------
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
SQLite의 query로 망설임이것은 내가 처음 안드로이드 응용 프로그램 개발에서 망설이고, 그 후 해결 된 방법을 비망록으로 철자하고 있습니다. java에서 SQLite를 이용한 애플리케이션을 작성하는 동안 EditText에 입력된 item이 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.