当前位置:网站首页>Oracle创建表、删除表、修改表(添加字段、修改字段、删除字段)语句总结
Oracle创建表、删除表、修改表(添加字段、修改字段、删除字段)语句总结
2022-07-28 05:16:00 【Ctrl练习生-谢哥哥blog】
创建表:
create table 表名 (
字段名1 字段类型 默认值 是否为空 ,
字段名2 字段类型 默认值 是否为空,
字段名3 字段类型 默认值 是否为空,
…
);
创建一个user表:
create table user (
id number(6) primary key, —主键
name varchar(50) not null, —姓名 不为null
sex varchar2(6) default ‘男’ check ( sex in (‘男’,‘女’)) —性别 默认’男’
);
修改表名:
rename 旧表名 to 新表名;
rename user to newuser;
删除表:
delete from 表名;
delete删除数据是一条一条的删除数据,后面可以添加where条件,不删除表结构。注意:如果表中有identity产生的自增id列,delete from后仍然从上次的数开始增加。
truncate table 表名;
truncate是一次性删掉所有数据,不删除表结构。注意:如果表中有identity产生的自增id列,truncate后,会恢复初始值。
drop table 表名;
drop删除所有数据,会删除表结构。
修改表:
添加新字段:
alter table 表名 add(字段名 字段类型 默认值 是否为空);
alter table user add(age number(6) null);
alter table user add (course varchar2(30) default ‘空’ not null);
alter table user add create_date date null;
给字段添加注释:comment on column table.create_date is ‘创建日期’;
修改字段:
alter table 表名 modify (字段名 字段类型 默认值 是否为空);
alter table user modify(age number(8));
修改字段名:
alter table 表名 rename column 列名 to 新列名;
alter table user rename column course to newcourse;
删除字段:
alter table 表名 drop column 字段名;
alter table user drop column course;
边栏推荐
- 多御安全浏览器将改进安全模式,让用户浏览更安全
- Google browser cannot open localhost:3000. If you open localhost, you will jump to the test address
- Read the paper -- a CNN RNN framework for clip yield prediction
- 基于MPLS构建虚拟专网的配置实验
- 2022 summer practice (first week)
- Dell remote control card uses ipmitools to set IPMI
- 【SLAM】LVI-SAM解析——综述
- Advanced assignment method of ES6 -- Deconstruction assignment
- [learning record] data enhancement 1
- 【CVPR2022】Lite Vision Transformer with Enhanced Self-Attention
猜你喜欢

Data security is gradually implemented, and we must pay close attention to the source of leakage

Duoyu security browser will improve the security mode and make users browse more safely

Professor dongjunyu made a report on the academic activities of "Tongxin sticks to the study of war and epidemic"

Win10 machine learning environment construction pycharm, anaconda, pytorch
![[paper notes] - low illumination image enhancement - zeroshot - rrdnet Network - 2020-icme](/img/e3/f9c6bfdbcd5dffd406e3f1d2331050.png)
[paper notes] - low illumination image enhancement - zeroshot - rrdnet Network - 2020-icme
![[internal mental skill] - creation and destruction of function stack frame (C implementation)](/img/a9/81644ee9ffb74a5dc8ff1bc3977f49.png)
[internal mental skill] - creation and destruction of function stack frame (C implementation)

SSLError

PC端-bug记录

Configuration experiment of building virtual private network based on MPLS

Flink mind map
随机推荐
Data imbalance: comprehensive sampling of anti fraud model (data imbalance)
HDU 1914 the stable marriage problem
分享几种管理C程序中标志位的方法
How to send and receive reports through outlook in FastReport VCL?
【计算机三级信息安全】信息安全保障概述
Message forwarding mechanism -- save your program from crashing
HDU 1530 maximum clique
HDU 2586 How far away ? (LCA multiplication method)
Keil Chinese garbled code solution
After ruoyi generates the code corresponding to the database, what should I do to make the following image look like
21 day SQL punch in summary
Mysql基本查询
使用nfpm制作rpm包
这种动态规划你见过吗——状态机动态规划之股票问题(中)
mysql的日期与时间函数,varchar与date相互转换
[internal mental skill] - creation and destruction of function stack frame (C implementation)
How should programmers keep warm when winter is coming
Advanced assignment method of ES6 -- Deconstruction assignment
Eccv2022 | 29 papers of Tencent Youtu were selected, including face security, image segmentation, target detection and other research directions
[learning record] data enhancement 1