当前位置:网站首页>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;
边栏推荐
- What is the reason why the easycvr national standard protocol access equipment is online but the channel is not online?
- yandex robots txt
- Reading sdwebimage source code Notes
- SSLError
- 多系统架构设计思考
- [internal mental skill] - creation and destruction of function stack frame (C implementation)
- Supervisor series: 5. Log
- list indices must be integers or slices, not tuple
- POJ 2763 housewife wind (tree chain partition + edge weighting point weight)
- 为什么md5不可逆,却还可能被md5免费解密网站解密
猜你喜欢

Paper reading notes -- crop yield prediction using deep neural networks

【CPU占用高】software_reporter_tool.exe

7. < tag string and API trade-offs> supplement: Sword finger offer 05. replace spaces

Test Development - UI testing in automated testing

PC side bug record

Mysql基本查询

How to send and receive reports through outlook in FastReport VCL?

Driving the powerful functions of EVM and xcm, how subwallet enables Boca and moonbeam

Tomato timing dimming table lamp touch chip-dlt8t10s-jericho

C language classic 100 question exercise (1~21)
随机推荐
SMD component size metric English system corresponding description
Class class added in ES6
[paper notes] - low illumination image enhancement - zeroshot - rrdnet Network - 2020-icme
【ARXIV2205】EdgeViTs: Competing Light-weight CNNs on Mobile Devices with Vision Transformers
FreeRTOS learning (I)
Online sql to XML tool
regular expression
Antd setfieldsvalue warning problem cannot use 'setfieldsvalue' until you use 'getfielddecorator' or
Handling of web page image loading errors
Share several methods of managing flag bits in C program
yandex robots txt
Paper reading notes -- crop yield prediction using deep neural networks
Check box error
SSLError
regular expression
How to successfully test php7.1 connecting to sqlserver2008r2
HashSet add
21 day SQL punch in summary
CPU and memory usage are too high. How to modify RTSP round robin detection parameters to reduce server consumption?
Confused, I'm going to start running in the direction of [test]