前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >数据库的增删改查和使用流程

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

作者头像
全栈程序员站长
发布2022-07-13 16:41:39
5530
发布2022-07-13 16:41:39
举报
文章被收录于专栏:全栈程序员必看

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

创建表 列名 类型,

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.cn/118274.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021年12月,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档