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

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

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

创建表                      列名 类型,
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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • java取整四舍五入_java取整和四舍五入

    java取整四舍五入_java取整和四舍五入Contents12345Math类里的两个方法:staticdouble(doublea)返回最大的(最接近正无穷大)double值,该值小于等于参数,并等于某个整数。staticdoubleceil(doublea)返回最小的(最接近负无穷大)double值,该值大于等于参数,并等于某个整数。123456789101112131415161718192021222324252627…

    2022年5月21日
    32
  • 视频编解码优化的几个概念[通俗易懂]

    视频编解码优化的几个概念[通俗易懂]视频编解码1.neon2.gpu加速3.汇编neon在移动平台上进行一些复杂算法的开发,一般需要用到指令集来进行加速。目前在移动上使用最多的是ARM芯片。ARM是微处理器行业的一家知名企业,其芯片结构有:armv5、armv6、armv7和armv8系列。芯片类型有:arm7、arm9、arm11、cortex系列。指令集有:armv5、armv6和neon指令。关于ARM到知识参考:ht

    2022年7月15日
    23
  • Linux系统开启IPv6任播(anycast)地址[通俗易懂]

    Linux系统开启IPv6任播(anycast)地址[通俗易懂]这两年真是在linux上各种掏捡,各种零碎。。。无力吐槽了。。。下面简单记录一下开启任播地址我的系统是Debian7.21、开启IPv6转发sudoecho1>/proc/sys/net/ipv6/conf/all/forwarding2、完了系统会自动生成IPv6任播地址cat/proc/net/anycast6此时你在网卡上新配置一个IPv6地址,就会在/proc/net/anycast6下生成一个对应的任播地址。在另一台主机上你可以ping6一下其中一个任.

    2022年5月23日
    54
  • According to TLD or attribute directive in tag file, attribute value does not accept any expressions

    According to TLD or attribute directive in tag file, attribute value does not accept any expressions

    2022年1月30日
    32
  • python标识符可以使用关键字_printf是关键字还是标识符

    python标识符可以使用关键字_printf是关键字还是标识符一、标识符用户自定义的、由程序使用的符号。不能是关键字由字母、数字、下划线组成。开头只能是字母和下划线。如:widthheightnamestudent二、关键字python预先定义了一部分具有特殊意义的标识符,用于自身使用,成为关键字或保留字。python常用关键字:33个…

    2025年10月10日
    4
  • JavaScript给元素添加class属性

    JavaScript给元素添加class属性注意:element.classList.remove()、element.classList.add()—ie9及以下不兼容//移除div的class属性obj.classList.remove(‘active’);//添加class属性值//方式一obj.className+=’newactive’;//方式二//obj.className=…

    2022年6月22日
    276

发表回复

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

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