当前位置:Gxlcms > 数据库问题 > 数据库操作学习

数据库操作学习

时间:2021-07-01 10:21:17 帮助过:5人阅读

        例如:          create table  people(id,name,age);   <2>删除表 sqlite>drop  table  <table_name>         例如:         drop table people;   <3>向表中添加新记录         sqlite>insert  into  <table_name>  values (value1, value2,…);         例如:         insert into people  values(1,‘A‘,10);         insert into people  values(2,‘B‘,13);         insert into people  values(3,‘C‘,9);         insert into people  values(4,‘C‘,15);         insert into people  values(5,NULL,NULL);         注意: 字符串要用单引号括起来。   <4>查询表中所有记录         sqlite>select  *  from  <table_name>;         例如 :         select   *   from  people;   <4>按指定条件查询表中记录    sqlite>select  *  from  <table_name>  where  <expression>;         例如:         在表中搜索名字是A的项所有信息          select  *  from  people  where  name=‘A‘;                  在表中搜索年龄>=10并且<=15的项的所有信息         select  *  from   people  where age>=10  and  age<=15;                  在表中搜索名字是C的项,显示其name和age         select name,age from people where name=‘C‘;           显示表中的前2项所有信息         select  *  from  people  limit  2;                  显示以年龄排序表中的信息         select * from people  order by age;          <6>按指定条件删除表中记录      sqlite>delete  from  <table_name>  where  <expression>                  例如:         删除表中名字是‘C‘的项         delete from pople  where name=‘C‘;   <7>更新表中记录           sqlite>update  <table_name>  set  <f1=value1>, <f2=value2>…   where  <expression>;                    例如:         将表中年龄是15并且ID是4项,名字改为CYG         update  people set  name=‘cyg‘  where  id=4 and  age=15;   <8>在表中添加字段            sqlite>alter table <table> add column <field> ;                  例如:         在people表中添加一个addr字段         alter table  people add column addr;           

数据库操作学习

标签:

人气教程排行