oracle课堂笔记
2015-12-29 10:30
447 查看
1、DOS登录
1.1、sqlplus 输入用户名、密码
1.2、sqlplus /nolog
conn 用户名/密码@ip地址/数据库名称 [如果是sys登录则必须加上as sysdba ,as sysoper]
conn system/orcl@orcl
conn system/orcl@192.168.0.1/orcl
conn sys/orcl@orcl as sysdba
1.3、sqlplus system/orcl
2、创建表空间
create tablespace ts_s3sn111ts --表空间名称
datafile 'E:\NF\Oracle\6.0\chapter11\S3SN111\s3sn111.dbf'
size 10M;
3、删除表空间
drop tablespace ts_s3sn111ts
4、创建用户指定表空间
create user s3sn111 --创建用户
identified by orcl --指定密码
default tablespace ts_s3sn111ts --指定默认表空间
5、授权
grant connect to s3sn111 --将连接数据库的权限授予用户s3sn111
grant dba to s3sn111
--drop tablespace ts_s3sn111ts --权限不足
--select * from scott.emp; --权限不足
grant resource to s3sn111 --将访问数据库资源的权限授予用户s3sn111
create table test2(Id int primary key);
insert into test(Id) values(4);
select * from test;
6、回收权限
revoke resource from s3sn111 --将用户s3sn111的资源使用权限回收
--dba最高权限
7、使用图形界面创建对象
8、创建表
--产品类型表
create table productType
(
id number(10,0) primary key not null,--主键,不为空,整数位10位
typename nvarchar2(100) not null --产品类型名称,长100个unicode字符
)
--产品表
create table products
(
id number(15,0) primary key not null,
title nvarchar2(128) not null,
typeId number(10,0) references productType(id),
price number(10,2) check(price>=0),
picture varchar(100),
addDate date default(sysdate),
memo clob
)
select sysdate from dual;
9、添加数据
9.1、单条
insert into productType(id,Typename) values(1,'数码');
insert into products
(id, title, typeid, price, memo)
values
(1, 'iphone 8s', 1, 100, '好用,便宜');
insert into products
(id, title, typeid, price,addDate,memo)
values
(2, '格力冰箱', 2, 1000,to_date('2015-01-10 23:23:23','YYYY-MM-dd HH24:MI:SS'),'好用,便宜');
SELECT to_date('2015-01-10 23:23:23','YYYY-MM-dd HH24:MI:SS') FROM DUAL
9.2、多条
insert into productType(id,Typename)
select 2,'家电' from dual union
select 3,'食品' from dual union
select 4,'服饰' from dual
select 12345 from dual; --虚表
10、查询数据
select id,Typename from productType
select id, title, typeid, price, picture, adddate from products
11、修改表
alter table products
add title nvarchar2(128) not null;
12、删除表
drop table products
1.1、sqlplus 输入用户名、密码
1.2、sqlplus /nolog
conn 用户名/密码@ip地址/数据库名称 [如果是sys登录则必须加上as sysdba ,as sysoper]
conn system/orcl@orcl
conn system/orcl@192.168.0.1/orcl
conn sys/orcl@orcl as sysdba
1.3、sqlplus system/orcl
2、创建表空间
create tablespace ts_s3sn111ts --表空间名称
datafile 'E:\NF\Oracle\6.0\chapter11\S3SN111\s3sn111.dbf'
size 10M;
3、删除表空间
drop tablespace ts_s3sn111ts
4、创建用户指定表空间
create user s3sn111 --创建用户
identified by orcl --指定密码
default tablespace ts_s3sn111ts --指定默认表空间
5、授权
grant connect to s3sn111 --将连接数据库的权限授予用户s3sn111
grant dba to s3sn111
--drop tablespace ts_s3sn111ts --权限不足
--select * from scott.emp; --权限不足
grant resource to s3sn111 --将访问数据库资源的权限授予用户s3sn111
create table test2(Id int primary key);
insert into test(Id) values(4);
select * from test;
6、回收权限
revoke resource from s3sn111 --将用户s3sn111的资源使用权限回收
--dba最高权限
7、使用图形界面创建对象
8、创建表
--产品类型表
create table productType
(
id number(10,0) primary key not null,--主键,不为空,整数位10位
typename nvarchar2(100) not null --产品类型名称,长100个unicode字符
)
--产品表
create table products
(
id number(15,0) primary key not null,
title nvarchar2(128) not null,
typeId number(10,0) references productType(id),
price number(10,2) check(price>=0),
picture varchar(100),
addDate date default(sysdate),
memo clob
)
select sysdate from dual;
9、添加数据
9.1、单条
insert into productType(id,Typename) values(1,'数码');
insert into products
(id, title, typeid, price, memo)
values
(1, 'iphone 8s', 1, 100, '好用,便宜');
insert into products
(id, title, typeid, price,addDate,memo)
values
(2, '格力冰箱', 2, 1000,to_date('2015-01-10 23:23:23','YYYY-MM-dd HH24:MI:SS'),'好用,便宜');
SELECT to_date('2015-01-10 23:23:23','YYYY-MM-dd HH24:MI:SS') FROM DUAL
9.2、多条
insert into productType(id,Typename)
select 2,'家电' from dual union
select 3,'食品' from dual union
select 4,'服饰' from dual
select 12345 from dual; --虚表
10、查询数据
select id,Typename from productType
select id, title, typeid, price, picture, adddate from products
11、修改表
alter table products
add title nvarchar2(128) not null;
12、删除表
drop table products
相关文章推荐
- Oracle 报错全记录
- oracle监听无法启动
- 【跟我学spring 4.0 】之第七节-spring使用外部属性文件-spring配置连接oracle数据库
- Oracle的oci和thin的不同
- oracle 11g如何完全卸载
- Oracle 11g R2安装手册(图文教程)For Windows
- Oracle VM VirtualBox 打开复制虚机报错
- ORACLE TO_CHAR函数格式化数字的出现空格的原因
- Oracle CASE WHEN 用法介绍
- oracle存储过程报"无效的列索引"的错误
- VS2015操作Oracle数据需要做那些设置?
- oracle 的那些事儿
- ORACLE 数据库的回滚要求
- Oracle EBS 交叉币种(3)-应收交叉币种
- RMAN实战16:ORACLE数据库的不完全恢复和闪回
- Oracle EBS 交叉币种(2)-应收交叉币种
- jdbc:oracle:thin:@192.168.3.98:1521:orcl(详解)
- 关于oracle 10g调度程序PLSQL_BLOCK方式无法使用truncate的问题
- Oracle EBS 交叉币种(1)-基础设置
- Oracle的四个主要用户