一、数据定义语言 DDLcreate table Student(sno varchar2(3) not null,sname varchar2(8) not null,ssex var
一、数据定义语言 DDL
create table Student
(
sno varchar2(3) not null,
sname varchar2(8) not null,
ssex varchar2(2) not null,
sbirthday date,
sclass varchar2(5)
)
二、数据操作语言 :添加(insert into)、修改(update set)、删除表中的数据(delete)
1. --增加数据
insert into student(sno,sname,ssex) values('102','张三','男');
--或者这样写
insert into student values('102','张三','男',sysdate,'95033');
2.--数据的修改
update student set ssex='女' where sno='102';
--如果不加where,便是修改整个表某列的属性
--对某一列数据的加减
update student set sclass=sclass+1;
update 表名 set 列名=列名+1 where 条件
3.--数据的删除
delete from student where sno=102;
delete from 表名 where 条件;
--不加where,即删除整个表,但是效率低,可用truncate table 表名来删除(先删表,再建表)
例:truncate table student;
三、数据查询语言 DQL:从表中获取数据(查询数据)。
--数据查询
select * from 表名;
--根据条件找字段
select sno,sname from student where sclass='95031';
select 字段名 from 表名 where 条件
物理删除与逻辑删除
--结束END--
本文标题: SQL增删改查
本文链接: https://www.lsjlt.com/news/38732.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-28
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0