Sub topic 5
Creating an Always Free Autonomous Database
This chapter assumes that you know basic SQL and can sign in to an Oracle Cloud account. You should also understand that a database client connects to a database service over a network. You do not need Docker or a local Oracle installation for this option.
Oracle Autonomous Database is a managed Oracle database in Oracle Cloud Infrastructure (OCI). Oracle manages the database software, backups, patching, and much of the infrastructure. The Always Free option provides a small database that you can use for learning without paying, subject to Oracle's current limits and availability rules.
Create the database
- Sign in to the Oracle Cloud Console.
- Open the navigation menu and choose Oracle Database, then Autonomous Database.
- Choose the cloud region where you want to create the database.
- Select Create Autonomous Database.
- Enter a display name and a database name.
- Select the Always Free option.
- Choose a workload type.
For general SQL practice, Transaction Processing is a useful choice. It supports ordinary tables, inserts, updates, and queries. The exact labels and database versions available in the console can change over time, so choose the current Always Free option shown in your account.
You must create an administrator password. This password is for the ADMIN database account. Use a long password that is different from your Oracle Cloud password. Store it in a password manager.
You can usually leave the default compute, storage, and network settings for a practice database. Review the summary, then choose Create. The status changes from provisioning to available. Initial creation can take several minutes.
flowchart TD
A[Open OCI Console] --> B[Choose Autonomous Database]
B --> C[Select a region]
C --> D[Choose Create Autonomous Database]
D --> E[Enable Always Free]
E --> F[Set workload and ADMIN password]
F --> G[Create database]
G --> H[Wait for Available]
H --> I[Open Database Actions]Open SQL in Database Actions
When the database is available, open its details page. Choose Database Actions or Database Actions Launchpad. This opens a browser-based set of tools connected to your Autonomous Database.
Open SQL from the Database Actions page. The SQL worksheet lets you enter and run SQL without installing SQL*Plus, SQLcl, or another client.
The worksheet starts with a connection for the ADMIN account. Use this account for initial administration only. Later, create a separate development account and use that account for ordinary practice.
Run this query to confirm the account and database service:
SELECT sys_context('USERENV', 'SESSION_USER') AS session_user,
sys_context('USERENV', 'SERVICE_NAME') AS service_name,
sys_context('USERENV', 'DB_NAME') AS database_name
FROM dual;SYS_CONTEXT reads information about the current session. A session is one active connection between a client and the database. The DUAL table is a built-in one-row table commonly used for expressions and system functions.
A successful result confirms that SQL is running in your Autonomous Database rather than in a local database or another cloud resource.
Other connection methods
Database Actions is the simplest connection method because the browser already knows how to reach the database. For connections from SQL Developer, SQLcl, applications, or scripts, open the database details page and choose DB Connection.
Autonomous Database normally provides connection information through a wallet or through TLS connection strings. A wallet is a package of connection files and certificates. TLS is the encryption protocol that protects data while it travels between your client and the database.
Download the wallet only to a machine you control. Treat it as sensitive configuration. The wallet does not replace the database password, but it can contain information needed to connect securely.
Confirm that SQL changes persist
Create a small table and insert one row in the worksheet:
CREATE TABLE cloud_practice_note (
id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
body VARCHAR2(200) NOT NULL
);
INSERT INTO cloud_practice_note (body)
VALUES ('Created in Autonomous Database');
COMMIT;
SELECT id, body
FROM cloud_practice_note;COMMIT makes the insert permanent for the transaction. Refreshing Database Actions or disconnecting and reconnecting should not remove the table. The table belongs to the account that created it, so another user will not automatically see it unless that user receives the required privileges.
Always Free resources can be stopped, reclaimed, or restricted under Oracle's service rules. Keep important practice scripts outside the database. Saving a script locally or in version control lets you recreate your tables if the resource is removed or you later create a different database.
Exercise
Which connection method should you use first when learning with an Always Free Autonomous Database, and why?
Show answer
Use Database Actions because it opens SQL in the browser and avoids installing a client, downloading a wallet, or configuring a local network connection.