Oracle12c 数据库建表空间及数据操作
更新时间:2023-09-17 23:44:01 阅读量: 幼儿教育 文档下载
- oracle12c推荐度:
- 相关推荐
Oracle12c 数据库建表空间及数据操作
--1、创建名字叫Java31的表空间
create tablespace Java31 datafile 'D:\\app\\hanq8202\\oradata\\orcl\\Java31.DBF' size 50M autoextend on next 32M maxsize unlimited;
--2、创建新用户c##hanq,在Oracle12c中必须在用户名前添加c##前缀
create user c##hanq identified by hq198202 default tablespace Java31;
--3、删除一个用户
drop user c##JAVA31 cascade;--用户已经被删除了 drop tablespace JAVA31 ;--用户已经被删除了
--4、给c##hanq用户添加权限
--授予用户权限的语法:gran 权限|角色 to 用户 --用户权限有:
--①、create session // 创建session的权限,即登陆权限 --②、unlimited tablespace //用户使用表空间的权限 --③、grant unlimited tablespace to tablename;//授予tablename用户使用表空间的权限
--④、grant create table to tablename;//授予创建表的权限
--⑤、grant drop any table to tablename;//授予删除表的权限,注意要加any关键字 --⑥、grant insert any table to tablename;//插入表的权限 注意要加any关键字 --⑦、grant update table to tablename;//修改表的权限 注意要加any关键字 --⑧、grant all to public;//这条比较重要,授予所有权限(all)给所有用户(public) grant connect ,resource to c##hanq; grant create table to c##hanq; grant drop any table to c##hanq; grant insert any table to c##hanq; grant update any table to c##hanq;
grant create view to c##hanq; grant select any table to c##hanq; grant dba to c##hanq;
--5、撤销用户的权限
--语法:revoke 权限|角色 from 用户名 revoke dba from c##hanq;
--6、创建表
--create [schema.]table (column datatype(length));
--schema:模式名,如果是在自己的模式中建表,模式名可以不写; --table:表名; --column:列名;
--datatype:数据类型; --length:数据宽度; create table stuInf (
stId number(30) not null primary key ,--学号 stName varchar2(100) not null,--姓名 stAge number(30) not null,--年龄 stGender varchar2(10)--性别 );
create table stuScore(
Scid number(30) not null, score number(10,1), stuId number (30) );
--7、alert table修改命令
alter table stuInf modify ( stId number(25));--修改stId列的属性
alter table stuInf add ( stuAdd varchar2(100),stuTel varchar2(30));--添加stuAdd和stuTel列
alter table stuInf add ( stuNo number(30));--添加stuNo列 alter table stuInf drop column stuNo;--删除stuNo列 alter table stuInf add ( stuEntrance date );
--8、truncate table 命令,不删除表结构的情况下,删除表中的所有行
truncate stuInf;
--9、desc命令,显示表结构
description stuInf;--在pl/sql环境下运行为无效的sql,在sqlplus下运行可以看到表结构
--10、sql语句创建、删除、查看约束
alter table stuInf add constraint UN_stTel unique (stuTel);--为stuTel列添加唯一键 alter table stuScore add constraint FK_stuId foreign key (stuId) references stuInf(stId);--为stuScore表中stuId添加外键,关联到stuInf表的stID alter table stuInf drop constraint UN_stTel ;--删除stuTel列的唯一建
--11、查看约束
select * from user_constraints where table_name ='stuInf'; select * from user_constraints where table_name ='stuScore';
--12、给表格添加数据
insert into stuInf (stId,stName,stAge,stGender,stuAdd,stuTel) values(1,'tom',20,'mail','USA','0987623'); select * from stuInf; insert into stuInf (stId,stName,stAge,stGender,stuAdd,stuTel,Stuentrance) values(2,'Andy',19,'femail','UK','987512',sysdate);--sysdate系统时间
update stuInf set stuEntrance = to_date('1980-12-23','yyyy-MM-dd') where stId =1;
正在阅读:
写给加入的一封感谢信12-11
04诱变育种05-28
手掌穴位按摩方法(附手部穴位图)02-02
上半年街道工作总结09-12
杭州居住证办理条件02-15
微经 习题12-08
工程建设项目招标投标法律实务03-17
我国保健品行业发展现状及趋势报告05-19
- 元旦晚会节目单
- 学案
- 光电显示技术期末复习资料 - 图文
- p2p与供应链结合案例
- 2016--2017学年度第二学期五年级班主任工作计划
- 尔雅2017年西藏的历史和文化期末考试满分答案解析
- 智慧树创新工程实践期末考试答案
- 六年级下美术教案-有趣的纸浮雕广西版
- 设备操作规程汇编
- 通信综合实训系统实验报告
- 南京财经大学金融学期末考试简答题
- 现代服务业发展规划研究 - 图文
- 锚杆支护工知识竞赛题
- 实验五
- 债权法习题集及详细解答
- 上海寺庙大全 - 图文
- 机会成本在企业决策中的应用研究
- 高考总复习语文选择题百题精炼第一季专题01 识记现代汉语字音(教师版)
- A9785-B中文资料
- 56m连续梁主墩冷却管布置技术交底
- Oracle12c
- 操作
- 数据库
- 数据
- 空间
- 贵州省考核考试(医博士培训考试试题及答案)
- 2011年7月自考真题烹饪原料学(5)
- 2009-2010初三年级浦东新区区中考一模英语试题
- 毕业论文 - 基于单片机的数字温度计 - 图文
- 乙酸乙酯皂化反应速率常数的测定
- 大学英语四级期末考试试卷(选修课)
- 人民法院司法警察执法细则
- 中国传统思维方式的特征 - 图文
- 2017尔雅先秦君子风范期末考试答案
- 德州经济技术开发区赵虎镇中学初中英语教学论文 关于中学英语教学的一些看法
- 2012-2017会考试题 - 经济生活 - 图文
- 高速
- 应该如何认后危机时代 doc
- 政治:2.3.2《政府的责任:对人民负责》同步测试(新人教版必修2)
- 应收款项习题及答案
- 第一单元复习大纲:物态及其变化
- PLC实验讲义
- 2015年造价工程师《土建工程计量》真题及答案(DOC)
- 顾家北100句翻译整理版
- 五年级应用题归类