当前位置:网站首页>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;
边栏推荐
- FreeRTOS personal notes - task notification
- How should programmers keep warm when winter is coming
- 数据库日期类型全部为0
- Interpretation of afnetworking4.0 request principle
- 11.< tag-动态规划和子序列, 子数组>lt.115. 不同的子序列 + lt. 583. 两个字符串的删除操作 dbc
- 【ARXIV2205】EdgeViTs: Competing Light-weight CNNs on Mobile Devices with Vision Transformers
- The default isolation level of MySQL is RR. Why does Alibaba and other large manufacturers change to RC?
- 【CVPR2022】Multi-Scale High-Resolution Vision Transformer for Semantic Segmentation
- Jsonp single sign on permission verification
- YUV to uiimage
猜你喜欢

Struct模块到底有多实用?一个知识点立马学习

Transformer -- Analysis and application of attention model

How practical is the struct module? Learn a knowledge point immediately

Read the paper -- a CNN RNN framework for clip yield prediction
![[high CPU consumption] software_ reporter_ tool.exe](/img/3f/2c1ecff0a81ead0448e1215567ede7.png)
[high CPU consumption] software_ reporter_ tool.exe

HashSet add
![Classes and objects [medium]](/img/0a/955d00d63f06e7e15e946599628edf.png)
Classes and objects [medium]

【ARIXV2204】Neighborhood attention transformer

The default isolation level of MySQL is RR. Why does Alibaba and other large manufacturers change to RC?

After ruoyi generates the code corresponding to the database, what should I do to make the following image look like
随机推荐
【CVPR2022】Lite Vision Transformer with Enhanced Self-Attention
Driving the powerful functions of EVM and xcm, how subwallet enables Boca and moonbeam
regular expression
从微服务基本概念到核心组件-通过一个实例来讲解和分析
C language: addition and deletion of linked list in structure
Reading sdwebimage source code Notes
The default isolation level of MySQL is RR. Why does Alibaba and other large manufacturers change to RC?
Read the paper -- a CNN RNN framework for clip yield prediction
Transformer -- Analysis and application of attention model
Check box error
[slam] lvi-sam analysis - Overview
Clickhouse填坑记2:Join条件不支持大于、小于等非等式判断
Interpreting the source code of cfrunloopref
如何在 FastReport VCL 中通过 Outlook 发送和接收报告?
How should programmers keep warm when winter is coming
Autoreleasepool problem summary
[internal mental skill] - creation and destruction of function stack frame (C implementation)
Win10 machine learning environment construction pycharm, anaconda, pytorch
jsonp 单点登录 权限检验
Configuration experiment of building virtual private network based on MPLS