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.处理结果

  • 相关阅读:
    js冒泡排序的两种实现方式
    LeetCode SQL(一)
    k8s学习之Mac安装最新版本k8s
    docker 安装MySQL8.0设置主从复制
    代码中if的骚操作
    和别人说东西的时候要注意的点
    2021 五一深圳计划
    Swoole支持openssl扩展Mac版
    租房
    Mac常用的快捷键
  • 原文地址:https://www.cnblogs.com/yxwkf/p/4025066.html
Copyright © 2011-2022 走看看