Data Base Oracle 常用命令

Data Base  Oracle 常用命令

1.登录:(不需要密码,属于管理员权限)

conn /as sysdba;

2.查看数据库存储位置:

select name from v$datafile;  

3.创建表空间:

语法:create tablespace 表空间名称 datafile '数据文件的路径' size 大小;

示例:create tablespace test_db datafile 'D:\ORACLE\ORADATA\ORCL\test_db.dbf' size 3000m;  

删除表空间:

--删除空的表空间,但是不包含物理文件
drop tablespace tablespace_name;
--删除非空表空间,但是不包含物理文件
drop tablespace tablespace_name including contents;
--删除空表空间,包含物理文件
drop tablespace tablespace_name including datafiles;
--删除非空表空间,包含物理文件
drop tablespace tablespace_name including contents and datafiles;
--如果其他表空间中的表有外键等约束关联到了本表空间中的表的字段,就要加上CASCADE CONSTRAINTS
drop tablespace tablespace_name including contents and datafiles CASCADE CONSTRAINTS;

4.创建用户:

语法:create user 用户名 identified by 密码 default tablespace 用户默认使用哪一个表空间;  

示例:create user test_db identified by test_db default tablespace test_db; 

删除用户:

drop user username cascade

5.修改密码:

语法:alter user 用户名 identified by 新密码;

示例:alter user scott identified by tiger;

6.解锁:

语法:alter user 用户名 account unlock;

示例:alter user test account unlock;

7.加锁:

语法:alter user 用户名 account lock;

示例:alter user test account lock;

8.授权:

语法:grant 角色1,角色2 to 用户名;  

示例:grant dba, connect to test_db;

9.连接远程oracle:

sqlplus username/password@//host:port/sid
sid:
常规的是:orcl
如果是域账号:orcl.域账号
10.导出:
exp
语法:exp 用户名/密码@tns file=路径 full=y;
示例:exp system/123456@orcl file=d:\test.dmp full=y;
11.导入:
语法:imp 用户名/密码@tns file=路径 full=y;
示例:imp system/123456@orcl file=d:\test.dmp full=y;
 

 

posted @   土豆哥  阅读(392)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
历史上的今天:
2015-08-12 java 乱码问题解决方案
点击右上角即可分享
微信分享提示