当前位置:网站首页>Oracle对表进行的常用修改命令
Oracle对表进行的常用修改命令
2022-07-06 15:59:00 【杰肥啊】
有时候我们做项目的时候不止只接触某一个单一数据库,MySQL
数据库或者Oracle
数据库,一般多多少少参与的过程中都要学习,接下来我将记录几个我们在Oracle
数据库中常用的几个操作命令,以便将来遇见了,有地方可以找到。
新增表的列字段
alter table 表名 add(
字段1 数据类型,
字段2 数据类型
);
--例子 在已存在的User表中添加一个地址字段`address`,数据类型为varchar2,长度为30
alter table user add(
address varchar2(30)
);
修改表的列字段
alter table 表名 modify(字段1 数据类型,.....)
--例子,修改已存在的User表中的地址字段`address`,数据类型为varchar2,长度为50
alter table user modify(address varchar2(50));
移除表的列字段
alter table 表名 drop column 字段
--例子,删除已存在的表User表中的地址字段`address`
alter table user drop column address
设置字段的注释
COMMENT ON COLUMN "表空间"."表名"."字段名" IS '注释内容';
--例子,设置已存在的User表中的地址字段`address`注释内容为'地址'
COMMENT ON COLUMN "scott"."user"."address" IS '地址';
分页模板
SELECT *
FROM (SELECT a.*, ROWNUM rn
FROM (
业务sql
) a
WHERE ROWNUM <= 最终偏移量)
WHERE rn >= 起始偏移量
--例子,查询User表的数据,展示第一页,每页20条数据
SELECT *
FROM (SELECT a.*, ROWNUM rn
FROM (
select * from user
) a
WHERE ROWNUM <= 20)
WHERE rn >= 1
创建表的序列
CREATE SEQUENCE "表空间"."序列名" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER NOCYCLE
--例子,创建user表的序列,用于递增id
CREATE SEQUENCE "scott"."user_S" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER NOCYCLE
边栏推荐
- Can online reload system software be used safely? Test use experience to share with you
- B 站弹幕 protobuf 协议还原分析
- The tutorial of computer reinstallation win10 system is simple and easy to understand. It can be reinstalled directly without U disk
- Flutter life cycle
- Talking about the current malpractice and future development
- Children's pajamas (Australia) as/nzs 1249:2014 handling process
- 电脑重装系统u盘文件被隐藏要怎么找出来
- Graphite document: four countermeasures to solve the problem of enterprise document information security
- MySQL implementation of field segmentation from one line to multiple lines of example code
- 【系统分析师之路】第七章 复盘系统设计(面向服务开发方法)
猜你喜欢
MySQL数据库之JDBC编程
koa2对Json数组增删改查
今日睡眠质量记录78分
js对JSON数组的增删改查
The method of reinstalling win10 system is as simple as that
How to implement Lua entry of API gateway
Experiment 4: installing packages from Gui
云原生(三十二) | Kubernetes篇之平台存储系统介绍
The problem of ASP reading Oracle Database
None of the strongest kings in the monitoring industry!
随机推荐
Use mitmproxy to cache 360 degree panoramic web pages offline
《数字经济全景白皮书》保险数字化篇 重磅发布
设计一个抢红包系统
本地部署 zeppelin 0.10.1
Why are some people still poor and living at the bottom of society even though they have been working hard?
短链的设计
Gold three silver four, don't change jobs
The important data in the computer was accidentally deleted by mistake, which can be quickly retrieved by this method
The intranet penetrates the zerotier extranet (mobile phone, computer, etc.) to access intranet devices (raspberry pie, NAS, computer, etc.)
实现多彩线条摆出心形
Gradle知识概括
不要再说微服务可以解决一切问题了
Gradle知識概括
Implementation steps of mysql start log in docker
同一个作业有两个source,同一链接不同数据库账号,为何第二个链接查出来的数据库列表是第一个账号的
浅谈现在的弊端与未来的发展
flinksql select id ,count(*) from a group by id .
【系统分析师之路】第七章 复盘系统设计(面向服务开发方法)
Entropy information entropy cross entropy
leetcode:236. The nearest common ancestor of binary tree