前言
如下,有 Oracle 23c 的产品和在线文档链接,也有 Docker 镜像、VM 虚拟机镜像以及 RPM 包三种安装方式的链接,我这里使用第二种,直接导入虚拟机 OVA 的方式,感兴趣朋友的可以用其他两种方式。
产品页面:https://www.oracle.com/database/free
下载地址:
Docker:https://container-registry.oracle.com/
VM:https://www.oracle.com/database/technologies/databaseappdev-vm.html
Linux RPM:https://www.oracle.com/database/technologies/free-downloads.html
在线文档:https://docs.oracle.com/en/database/oracle/oracle-database/23/index.html
( 23c 生命周期)
(只有 19c 和 21c 可以直接升级到 23c)
第一步 下载虚拟机 OVA 文件
Oracle Database 23c Free - Developer Release VirtualBox Appliance
请注意,此设备仅用于开发和测试目的,因此不受支持,不应在生产环境中使用。此虚拟机包含:
Oracle Linux 8.7
Oracle Database 23.2 Free - Developer Release for Linux x86-64
Oracle REST Data Services 23.1
Oracle SQLcl 23.1
Oracle APEX 22.2
安装要求:
至少 4GB RAM。
至少有 20GB 的可用空间
6,996,213,760 bytes bytes, md5sum:a802c5870e0c42da25e0d351a822320a , sha1:c6b2925eae4351376c15144ae278162ba533350d
Oracle 数据库免费安装和运行时限制
Oracle Database Free 将其自身限制为每个逻辑环境只能安装一次。逻辑环境可以是诸如 VM 或容器之类的虚拟主机,也可以是物理主机。如果您试图在这样的逻辑环境中启动多个 Oracle Database Free 安装,则会显示 ORA-00442:Oracle Database Free 单实例冲突错误,并且您的数据库不会启动。
这不会影响 Oracle Database Standard Edition 2 或Oracle Database Enterprise Edition 的任何现有安装或新安装。
Oracle 数据库免费用户数据限制
Oracle Database Free 中的最大用户数据量不能超过 12 GB。如果用户数据增长超过此限制,则系统显示 ORA-122592 错误。
Oracle数据库可用 RAM 内存限制
Oracle Database Free 的最大 RAM 量不能超过 2 GB,即使有更多可用 RAM。
第二步 导入虚拟机
选择下载好的 OVA 文件,导入到 Virtual box 6.1 虚拟机。
第三步 启动虚拟机
点击启动下拉箭头,选择无界面启动或者分离式启动,不要直接点击启动,否则就会和我一样报错。
结果报错了:The virtual machine ‘Oracle DB Developer VM’ has terminated unexpectedly during startup with exit code 1 (0x1). More details may be available in ‘D:\Virtual_Machine\【VBOX】\Oracle DB Developer VM\Logs\VBoxHardening.log’.
这个报错网上找了好久,又说不兼容的要升级 VBOX 的,又说要用管理员权限启动的,又说要改注册表的等等,折腾了好久好久,最后网上找了一篇 【Virtual box 6.1 0x80004005 错误】,说明启动方式的问题,不能直接点启动,需要用到下面的两种启动方式,我这里点击无界面启动,则正常启动了。那么快来体验一把 Oracle 23c free 版本吧。
登入之后便看到如下提示语。
*** Oracle Database 23c Free – Developer Release is the first release of the next-generation Oracle Database,
allowing developers a head-start on building applications with innovative 23c features that simplify development
of modern data-driven apps. The entire feature set of Oracle Database 23c is planned to be generally available
within the next 12 months. ***
*** Please note that this appliance is for testing purposes only,
as such it is unsupported and should not be used as a production environment. ***
Database Information:
Oracle SID : free
Pluggable DB : freepdb1
ALL PASSWORDS ARE : oracle
Sample schemas have been preloaded (HR, OE, PM, IX, BI, AV, SH) for your convenience.
Oracle REST Data Service (ORDS) and APEX are both installed, configured, and available at startup.
Port Forwards are defined for HTTP and SQL*Net, these are configurable in the Virtual Machine settings.
8080:8080
1521:1521
From your host, simply launch:
http://localhost:8080/ords to launch APEX
http://localhost:8080/ords/sql-developer to start SQL Developer Web
sql hr/oracle@localhost:1521/freepdb1 tp get a SQLcl session for the Pluggable Database (PDB)
sql system/oracle@localhost:1521/free to get a SQLcl session for the Container Database (CDB)
The HR schema is REST enabled, you can login to SQL Developer Web using:
HR/oracle
登录进来之后,看到提示所有用户密码都是 Oracle,实例名 free 端口号 1521,并提供了 http 和 sql 命令行访问方式,那么就来体验一把吧。
首先看下环境变量
注意在环境变量最后一行,这里使用了 TWO_TASK=FREEPDB1,这样则直接会连接到 PDB 实例,而且 SYS 登录时也需要输入密码才可以。
[oracle@localhost ~]$ more .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
if test "m$JAVAENV" = "m"
then
export TMZ="GMT"
export JAVA_HOME=`ls -d /home/oracle/java/jdk* 2>/dev/null`
if test "m$JAVA_HOME" = "m"
then
export JAVA_HOME=/opt/oracle/product/23c/dbhomeFree/jdk
fi
export PATH=$JAVA_HOME/bin:/home/oracle/bin:/home/oracle/sqlcl/bin:/home/oracle/sqldeveloper:/home/oracle/datamodeler:$P
ATH:/home/oracle/sqlcl/bin:/home/oracle/sqldeveloper:/home/oracle/bin
export JAVAENV=true
fi
if test "m$JAVAENV" = "m"
then
export TMZ="GMT"
export JAVA_HOME=`ls -d /home/oracle/java/jdk* 2>/dev/null`
if test "m$JAVA_HOME" = "m"
then
export JAVA_HOME=/opt/oracle/product/23c/dbhomeFree/jdk
fi
export PATH=$JAVA_HOME/bin:/home/oracle/bin:/home/oracle/sqlcl/bin:/home/oracle/sqldeveloper:/home/oracle/datamodeler:$P
ATH:/home/oracle/sqlcl/bin:/home/oracle/sqldeveloper:/home/oracle/bin
export JAVAENV=true
fi
#LD_LIBRARY_PATH
#set up db for su login and gnome terminal use so LD_LIBRARY_PATH pure for gnome and user does not have to . oraenv
#do I still get ui issues "m1" = "m0" ie is it really an issue of these 10 lines ( and install). -a "m1" = "m0"
pstree -s $$ | egrep "\-su-|gnome-terminal" >/dev/null 2>&1
export GNOME_CHECK=$?
if test "m$DBENV" = "m" -a "m$GNOME_CHECK" = "m0"
then
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_UNQNAME=FREE
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/23c/dbhomeFree
export ORACLE_SID=FREE
#LD_LIBRARY_PATH
export PATH=/home/oracle/bin:/home/oracle/LDLIB:$ORACLE_HOME/bin:/usr/sbin:$PATH
#during install set LD_LIBRARY_PATH otherwise rely on LDLIB wrappers and ~/bin/sql sqlplus and modeller
if test -f /tmp/1/buildTimeStillInstalling
then
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
fi
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export DBENV=true
#export SQL_OR_SQLPLUS=sql -oci
export SQL_OR_SQLPLUS=sqlplus
fi
if test "m$DONOTSETTWO_TASK" = "m"
then
export TWO_TASK=FREEPDB1
fi
登录数据库
使用 sqlplus / as ssydba 无法直接登录,只能使用密码登录。进入后直接到 PDB1,有一个 PDB 实例 FREEPDB1,数据库版本为 23.2 基础版本。
SQL> select banner_full from v$version;
BANNER_FULL
--------------------------------------------------------------------------------
Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0
切换到 CDB 根容器
默认就会登录到 PDB1
[oracle@localhost ~]$ sql sys/oracle as sysdba
SQLcl: Release 23.1 Production on Fri Apr 07 03:36:26 2023
Copyright (c) 1982, 2023, Oracle. All rights reserved.
Connected to:
Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0
SQL> select file_id,file_name from dba_data_files;
FILE_ID FILE_NAME
__________ __________________________________________________
12 /opt/oracle/oradata/FREE/FREEPDB1/system01.dbf
13 /opt/oracle/oradata/FREE/FREEPDB1/sysaux01.dbf
14 /opt/oracle/oradata/FREE/FREEPDB1/undotbs01.dbf
15 /opt/oracle/oradata/FREE/FREEPDB1/users01.dbf
SQL> sho pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
_________ ___________ _____________ _____________
3 FREEPDB1 READ WRITE NO
SQL> alter session set container=freepdb1;
Session altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
_________ ___________ _____________ _____________
3 FREEPDB1 READ WRITE NO
SQL> alter session set container=CDB$ROOT;
Session altered.
SQL> sho pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 FREEPDB1 READ WRITE NO
创建表空间及用户
SQL> sho pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
_________ ___________ _____________ _____________
3 FREEPDB1 READ WRITE NO
SQL>
SQL> select name from v$datafile;
NAME
__________________________________________________
/opt/oracle/oradata/FREE/FREEPDB1/system01.dbf
/opt/oracle/oradata/FREE/FREEPDB1/sysaux01.dbf
/opt/oracle/oradata/FREE/FREEPDB1/undotbs01.dbf
SQL>
SQL> create tablespace JiekeXu datafile '/opt/oracle/oradata/FREE/FREEPDB1/JiekeXu01.dbf' size 200m;
Tablespace JIEKEXU created.
SQL> select name from v$datafile;
NAME
__________________________________________________
/opt/oracle/oradata/FREE/FREEPDB1/system01.dbf
/opt/oracle/oradata/FREE/FREEPDB1/sysaux01.dbf
/opt/oracle/oradata/FREE/FREEPDB1/undotbs01.dbf
/opt/oracle/oradata/FREE/FREEPDB1/users01.dbf
/opt/oracle/oradata/FREE/FREEPDB1/JiekeXu01.dbf
SQL> create user JiekeXu identified by oracle default tablespace JiekeXu;
User JIEKEXU created.
SQL> select username,account_status,default_tablespace from dba_users where account_status='OPEN';
USERNAME ACCOUNT_STATUS DEFAULT_TABLESPACE
________________________ _________________ _____________________
SYS OPEN SYSTEM
SYSTEM OPEN SYSTEM
APEX_LISTENER OPEN SYSAUX
APEX_PUBLIC_USER OPEN SYSAUX
APEX_REST_PUBLIC_USER OPEN SYSAUX
AV OPEN USERS
PDBADMIN OPEN USERS
SYSRAC OPEN USERS
HR OPEN USERS
ORDS_PUBLIC_USER OPEN USERS
ORDS_METADATA OPEN USERS
BI OPEN USERS
OE OPEN USERS
PM OPEN USERS
HRREST OPEN USERS
IX OPEN USERS
SH OPEN USERS
JIEKEXU OPEN JIEKEXU
18 rows selected.
SQL> grant connect,resource,unlimited tablespace to JiekeXu;
Grant succeeded.
--创建只读用户
SQL> create user JiekeXu_sel identified by oracle default tablespace users;
User created.
SQL> grant connect to JiekeXu_sel;
Grant succeeded.
如下,使用普通用户去连接建表插入数据,默认已经配置一个了 tns 连接串 FREEPDB1。
新特性新功能体验
图片来自甲骨文云技术,这只是部分新列表,正式版的发布可能有变化。
后面就可以体验新的数据库新的功能了,例如 不带 from 的 SQL 语句,DDL的 IF EXISTS判断,schema 级别的授权,布尔数据类型,基于别名的GROUP BY等,快来体验吧。
SQL> select sysdate from dual;
SYSDATE
____________
07-APR-23
SQL> select sysdate;
SYSDATE
____________
07-APR-23
-----------------------------------------------------
[oracle@localhost ~]$ sql hr/oracle
SQLcl: Release 23.1 Production on Fri Apr 07 03:51:21 2023
Copyright (c) 1982, 2023, Oracle. All rights reserved.
Connected to:
Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0
SQL>
SQL> desc Customers
ERROR:
ORA-04043: object Customers does not exist
SQL>
SQL> CREATE TABLE IF NOT EXISTS Customers (ID NUMBER(10), Name VARCHAR2(100));
Table CUSTOMERS created.
SQL> DROP TABLE IF EXISTS Customers;
Table CUSTOMERS dropped.
SQL> DROP TABLE IF EXISTS Customers;
Table CUSTOMERS dropped.
SQL> CREATE TABLE Customers (ID NUMBER(10), Name VARCHAR2(100), ACTIVE BOOLEAN);
Table CUSTOMERS created.
SQL> sho user
USER is "SYS"
SQL> sho pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
3 FREEPDB1 READ WRITE NO
SQL> grant select any table on schema JIEKEXU to JIEKEXU_SEL;
Grant succeeded.
SQL>
SQL> select username,account_status,default_tablespace from dba_users where account_status='OPEN';
USERNAME ACCOUNT_STATUS DEFAULT_TABLESPACE
------------------------ -------------------------------- ------------------------------
SYS OPEN SYSTEM
SYSTEM OPEN SYSTEM
APEX_LISTENER OPEN SYSAUX
APEX_PUBLIC_USER OPEN SYSAUX
APEX_REST_PUBLIC_USER OPEN SYSAUX
AV OPEN USERS
PDBADMIN OPEN USERS
SYSRAC OPEN USERS
HR OPEN USERS
ORDS_PUBLIC_USER OPEN USERS
ORDS_METADATA OPEN USERS
BI OPEN USERS
OE OPEN USERS
PM OPEN USERS
JIEKEXU_SEL OPEN USERS
HRREST OPEN USERS
IX OPEN USERS
SH OPEN USERS
JIEKEXU OPEN JIEKEXU
19 rows selected.
SQL> conn JiekeXu/oracle@FREEPDB1
Connected.
SQL> select * from TAB;
TNAME TABTYPE CLUSTERID
-------------------------------------------------------------------------------------------------------------------------------- ------------- ----------
TEST TABLE
SQL> create table test2 as select * from TAB;
Table created.
SQL> col TNAME for a15
SQL> select * from TAB;
TNAME TABTYPE CLUSTERID
--------------- ------------- ----------
TEST TABLE
TEST2 TABLE
SQL> conn JiekeXu_SEL/oracle@FREEPDB1
Connected.
SQL> select * from TAB;
no rows selected
SQL> select count(*) from JiekeXu.TEST;
COUNT(*)
----------
5
SQL> select count(*) from JiekeXu.TEST2;
COUNT(*)
----------
2
SQL> conn sys/oracle as sysdba
Connected.
SQL> grant select any table on schema SH to JIEKEXU_SEL;
Grant succeeded.
SQL> grant select any table on schema SH to JIEKEXU;
Grant succeeded.
SQL> grant select any table on schema HR to JIEKEXU;
Grant succeeded.
客户端工具连接
在虚拟机里的火狐浏览器中使用自带的页面,打开 http://localhost:8080/ords/sql-developer 来开启 SQL Developer Web 界面。
使用 hr 用户,其他用户登录报错。这个 web 界面实在是太卡了,看来内存太小了还是不行呀。
全文完,希望可以帮到正在阅读的你,如果觉得此文对你有帮助,可以分享给你身边的朋友,同事,你关心谁就分享给谁,一起学习共同进步~~~
欢迎关注我的公众号【JiekeXu DBA之路】,第一时间一起学习新知识!
————————————————————————————
公众号:JiekeXu DBA之路
CSDN :https://blog.csdn.net/JiekeXu
墨天轮:https://www.modb.pro/u/4347
腾讯云:https://cloud.tencent.com/developer/user/5645107
————————————————————————————