前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >oracle数据库的常用的命令操作!

oracle数据库的常用的命令操作!

作者头像
Java学习
发布2018-04-16 11:24:26
7450
发布2018-04-16 11:24:26
举报
文章被收录于专栏:java学习java学习

Java基础 | 数据库 | Android | 学习视频 | 学习资料下载

最新通知 数据库技术是计算机科学技术的一个重要分支。从20世纪50年代中期开始,计算机应用从科学研究部门扩展到企业管理及政府行政部门,人们对数据处理的要求也越来越高。传统的文件系统已经不能满足人们的需要。 ★回复【数据库工具】获取数据库安装包以及安装视频教程链接

熟记一下单词 select 选择 create 创建 insert 插入 alter 更改 modify 修改 update 更新 drop 删掉 delete 删除 constraint 约束 reference 参考 unique 唯一 check 检查 primary key 主建 foreign key 外键

表的基本操作

--建表people(表名)

create table people

(

--定义列

--字段名 类型

people_id int ,

people_cash number(5,2),

people_name varchar2(100),

people_num char(8),

people_brithday date --最后一行不需要逗号,

); --这里需要分号

--修改表

--alter table 表名 操作 字段名 类型

--添加字段名

alter table peopleadd people_genderchar(2);

--删除字段名(列名)

alter table peopledrop column people_gender;

--修改字段类型

alter table peoplemodify people_num char(20);

--删除表

drop table people;

--恢复

flashback table people to before drop;

--重命名格式 rename 新的表名 to 旧的表名

rename new_peopleto people;

--查询 *表示所有 你也可以指定查询某个字段

select * from people;

--给表添加数据格式 insert into 表名(字段名,字段名。。。。)valuse(值)

insert into people(people_name,PEOPLE_NUM)values('刘德华','34556');

commit;

字段的约束操作

create table t_student

(

--第一种在建表时定义约束

--字段名 类型约束条件

stu_id int primary key

stu_num char(10) not null,

stu_name varchar2(30)not null,

stu_age int ,

stu_gender char(2),

stu_state char(10) default 'A'

--第二种定义约束方法

-- constraint 约束名称约束条件

--constraint PK_stu_id primary key(stu_id), --注意上面stu_id已经定义过主键约束了

--constraint CK_stu_gender check(stu_genderin ('男','女'))

);

--第三种方法(在建表后定义约束)

-- alter table 表名 add constraint 约束名称 约束条件

--添加主键约束(唯一 非空)

alter table t_student add constraint PK_stu_idprimary key(stu_id);

--添加唯一约束

alter table t_student add constraint UQ_stu_numunique(stu_num);

--添加检查约束 表示年龄只能在18到50之间

alter table t_student add constraint CK_stu_agecheck(stu_age between 18 and 50);

--管理约束

--删除约束

alter table t_student drop constraint CK_stu_age;

--禁用约束

alter table t_student modify constraint CK_stu_age disable;

--启动约束

altertable t_student modify constraint CK_stu_age enable;


1、多表查询

2、基本查询、where查询和排序查询

3、分组查询

4、事务

等等(有待更新。。。。。)

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2017-06-25,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 java学习 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 表的基本操作
  • 字段的约束操作
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档