数据库的增删改查和使用流程

数据库的增删改查和使用流程

大家好,又见面了,我是全栈君,祝每个程序员都可以多学几门语言。

创建表                      列名 类型,
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.处理结果

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/118274.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • PO模式实践「建议收藏」

    PO模式实践「建议收藏」目标1.能够采用PO模式的分层思想对页面进行封装1.V4版本采用PO模式的分层思想对代码进行拆分1.1PO分层封装对登录页面进行分层封装:对象库层:LoginPage操作层:LoginHandle业务层:LoginProxy调用业务层的方法,编写测试用例:测试用例:TestLogin1.2示例代码frompo.utilsimpo…

    2022年6月11日
    99
  • python3·7创建虚拟环境_python激活虚拟环境

    python3·7创建虚拟环境_python激活虚拟环境Centos7安装Python3,创建python3虚拟环境

    2022年9月13日
    0
  • 简单介绍一下spring bean的生命周期_java类的生命周期

    简单介绍一下spring bean的生命周期_java类的生命周期1.springbean生命周期2.Aware接口2.1.作用一个标记,标记在spring容器初始化时需要获取上下文中当前的一些运行环境;2.2.常用接口ApplicationContextAware:获取ApplicationContextspring上下文;ApplicationEventPublisherAware:获取ApplicationEventPublisher事件发布器;BeanClassLoaderAware:获取当前的ClassLoader类加载器;BeanFac

    2022年9月15日
    0
  • 教你如何把M3U8转换成MP4丨NueXini M3U8 Downloader

    教你如何把M3U8转换成MP4丨NueXini M3U8 Downloader准备工具:https://www.lanzous.com/i18d7sh步骤:1.下载软件并且解压到非中文目录,然后打开主程序2.把M3U8的网络地址,或者下载到本地的M3U8文件拖入编辑框(红色箭头)3.点击解析(这里使用网络地址:http://nuexini.shop/ceshi.m3u8)4.点击开始(软件自动下载并且完成合并)5.完成!!!…

    2022年6月24日
    41
  • 一步步学习Linux开发环境搭建与使用

    一步步学习Linux开发环境搭建与使用

    2022年1月22日
    42
  • Oracle insert all 详解

    Oracle insert all 详解文章目录1概述2insert的两种形式2.1insertfirst2.2insertall3数据一致性(同时插入)2.1验证:insertinto数据不一致2.2验证:insertall数据一致1概述1.作用:’正确、高效’的将’同一批数据’插入至’不同的表’中2.好处(1)’正确’:避免数据差异(2)’高效’:优于写多个insertinto(因为无论插入多少张表,’主表’只会被读取一次)3.场景,若需求:将表t中

    2022年7月25日
    18

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号