当前位置:网站首页>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;
边栏推荐
- Eccv2022 | 29 papers of Tencent Youtu were selected, including face security, image segmentation, target detection and other research directions
- 【ARXIV2203】Efficient Long-Range Attention Network for Image Super-resolution
- How should programmers keep warm when winter is coming
- 在ruoyi生成的对应数据库的代码 之后我该怎么做才能做出下边图片的样子
- Autoreleasepool problem summary
- Offline loading of wkwebview and problems encountered
- HDU 2874 connections between cities
- Gym 101911c bacteria (minimum stack)
- Confused, I'm going to start running in the direction of [test]
- New modularity in ES6
猜你喜欢

Win10 machine learning environment construction pycharm, anaconda, pytorch
![[high CPU consumption] software_ reporter_ tool.exe](/img/3f/2c1ecff0a81ead0448e1215567ede7.png)
[high CPU consumption] software_ reporter_ tool.exe

Configuration experiment of building virtual private network based on MPLS
![[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

【内功心法】——函数栈帧的创建和销毁(C实现)

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

为什么md5不可逆,却还可能被md5免费解密网站解密

【CVPR2022】Multi-Scale High-Resolution Vision Transformer for Semantic Segmentation

Database date types are all 0

From the basic concept of micro services to core components - explain and analyze through an example
随机推荐
C language: some self realization of string functions
【ARXIV2205】Inception Transformer
Message forwarding mechanism -- save your program from crashing
MySQL 默认隔离级别是RR,为什么阿里等大厂会改成RC?
Clickhouse填坑记2:Join条件不支持大于、小于等非等式判断
POJ 3728 the merchant (online query + double LCA)
【CPU占用高】software_reporter_tool.exe
From the basic concept of micro services to core components - explain and analyze through an example
HDU 2874 connections between cities
C language classic 100 question exercise (1~21)
Have you learned the common SQL interview questions on the short video platform?
多系统架构设计思考
测试开发---自动化测试中的UI测试
CPU and memory usage are too high. How to modify RTSP round robin detection parameters to reduce server consumption?
Anaconda common instructions
SSLError
DELL远程控制卡 使用ipmitools设置ipmi
Check box error
Professor dongjunyu made a report on the academic activities of "Tongxin sticks to the study of war and epidemic"
Autoreleasepool problem summary