sql 语句(DDL、DML)

注释:
--:表示单行注释
/* */:多行注释


DDL语言


建表:格式
create table 表名(
colName dataType,
colName dataType,
......
colName dataType
);
ex:
create table temp_1(
id number(4),
name varchar2(20),
gender char(1),
birth date
);

修改表的结构 alter
增加表的字段
格式:alter table tname add(colname datetype);
ex: alter table temp_1 add(tage number(2)); 
删除表的字段
格式:alter table tname drop column colname;
ex: alter table temp_1 drop column tage;
修改字段名称
格式:alter table tname rename column colname to newname;
ex: alter table temp_1 rename column id to no;
修改字段的数据类型
格式:alter table tname modify colname datatype;
ex: alter table temp_1 modify name varchar2(30);


修改表名
格式:rename oldtname to newtname;
ex: rename temp_1 to temp;
删除表结构
格式:drop table tname;
ex: drop table temp;
查看表结构
格式:desc tname;
ex: desc temp;


DML语言

向表中插入数据  insert
格式1: insert into tname(colname,colname...) values(val1,val2...);
格式2: insert into tname(val1,val2....);  赋值顺序要与建表顺序一致,个数不能少,没有的用null代替。
ex: insert into temp_1 (tid,tname) values(1003,'王五');
   insert into temp_1 values(1004,'赵六',null,null);


删除表中数据 delete
格式:delete from tname where 条件;
ex: delete from temp where id=1;  删除temp 表 id字段里为1的数据


修改表中数据 update
格式:update 表名 set colname='新值' where colname='某值';
ex; update temp set id=5 where name='王五'; 在temp表中将王五的id修改为5

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值