zoukankan      html  css  js  c++  java
  • 数据库操作学习

    <1>创建新表
       sqlite>create  table  <table_name>  (f1  type1, f2  type2,…);
            例如:
             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;
            
     
  • 相关阅读:
    Introduction to debugging neural networks
    Faster R-CNN教程
    最长递增子序列
    321. Create Maximum Number 解题方法详解
    Ubuntu安装opencv with cuda
    转载:LeetCode:5Longest Palindromic Substring 最长回文子串
    64. Minimum Path Sum
    322. Coin Change
    148. Sort List
    微信浏览器禁止页面下拉查看网址(不影响页面内部scroll)
  • 原文地址:https://www.cnblogs.com/lzh-Linux/p/4550354.html
Copyright © 2011-2022 走看看