zoukankan      html  css  js  c++  java
  • 数据库的增删改查和使用流程

    创建表                      列名 类型,
    1...create table Student (id integer , name text, sex text, age  integer)

    2…create table  if not exists Student  (id integer , name text default '张三' , sex text not null, age  integer)

    删除表       表名
    drop table Student

    插入
    所有列插入       表名              值               
    insert into Student values (1, ‘张三’, ’男’, 18)
    部分列插入
    insert into Student (name, sex) values ( 'lisi', 'nv')

    主键 (唯一, 不能反复)
    create table Student (id integer primary key,name text, age integer, sex text )

    查询
    全部数据
    select * from Student
    查询姓名这一列 / 两列
    select name from Student
    select name, sex from Student
    条件查询
    select * from Student where age > 10
    select * from Student where age > 10 and sex = 'nv'
    select * from Student where age between 15 and 20

    升序/降序
    select * from Student order by id sac / desc
    仅仅要前 5 条
    select * from Student order by id asc limit 5

    改动
    1列
    update Student set age = 18 where sex = ‘男’
    多列(勿忘逗号分隔)
    update Student set age = 16 , sex = '男'  where age < 19

    删除
    数据
    delete from Student where sex = ‘男'
    所有
    delete from Student

    使用sqlite
    1.打开数据库
    2.运行sql,做出数据处理
    3.关闭数据库

    操作
    1.打开数据库
    2.创建一个数据操作指针 stmt
    3.运行sql 语句
    4.处理结果

  • 相关阅读:
    [HAOI2016]食物链
    [TJOI2011]序列
    P2548 [AHOI2004]智能探险车
    [JSOI2008]最大数
    模板之dinic
    Excim的NOIP2017游记
    数列排序
    Car的旅行路线
    [HAOI2006]均分数据
    [luogu2210] Haywire
  • 原文地址:https://www.cnblogs.com/yxwkf/p/4025066.html
Copyright © 2011-2022 走看看