### Install GORM and Oracle Dialect Source: https://github.com/oracle/skills/blob/main/db/frameworks/gorm-oracle.md Install the necessary GORM and gorm-oracle packages using go get. ```bash go get gorm.io/gorm go get github.com/godoes/gorm-oracle ``` -------------------------------- ### GoldenGate Setup: Initial Bulk Load and Capture Source: https://github.com/oracle/skills/blob/main/db/migrations/migration-cutover-strategy.md This bash script demonstrates the initial setup for Oracle GoldenGate, including starting the extract process on the source to capture transaction logs and performing an initial bulk data load. ```bash # Start GoldenGate Extract on source (begin capturing changes from this SCN/LSN) GGSCI> ADD EXTRACT ext_src, TRANLOG, BEGIN NOW GGSCI> ADD EXTTRAIL ./dirdat/et, EXTRACT ext_src GGSCI> START EXTRACT ext_src # While GoldenGate is capturing, perform initial bulk load via Data Pump or SQL*Loader # This can take hours for large databases expdp source_user/pass TABLES=... DUMPFILE=initial_load.dmp impdp oracle_user/pass DUMPFILE=initial_load.dmp TABLE_EXISTS_ACTION=APPEND ``` -------------------------------- ### Install godror Driver Source: https://github.com/oracle/skills/blob/main/db/appdev/golang-oracle.md Install the godror Go driver using go get. Ensure Oracle Instant Client is installed and configured in the library path. ```bash go get github.com/godror/godror ``` -------------------------------- ### Start SQLcl Daemon Source: https://github.com/oracle/skills/blob/main/db/sqlcl/sqlcl-scheduler-daemon.md Starts the SQLcl daemon as a background process. Ensure SQLcl is installed and JRE is available. ```shell sql -daemon start ``` -------------------------------- ### Enable and Start SQL Scheduler Source: https://github.com/oracle/skills/blob/main/db/backup-recovery/cloud-protect.md Enables the SQL scheduler to start on boot and starts the service. Verifies the status of the scheduler service. ```bash systemctl enable sql-scheduler systemctl start sql-scheduler systemctl status sql-scheduler ``` -------------------------------- ### GitHub Actions CI/CD Deployment Source: https://github.com/oracle/skills/blob/main/db/sqlcl/sqlcl-liquibase.md Automate database deployments using GitHub Actions. This example installs SQLcl, sets up an Oracle Wallet, and applies Liquibase changesets. ```yaml name: Deploy Database Changes on: push: branches: [main] paths: - 'db/**' jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install SQLcl run: | wget -q https://download.oracle.com/otn_software/java/sqldeveloper/sqlcl-latest.zip unzip -q sqlcl-latest.zip -d /opt/sqlcl echo "/opt/sqlcl/sqlcl/bin" >> $GITHUB_PATH - name: Set up wallet run: | mkdir -p /tmp/wallet echo "${{ secrets.WALLET_ZIP_B64 }}" | base64 -d > /tmp/wallet.zip unzip /tmp/wallet.zip -d /tmp/wallet env: TNS_ADMIN: /tmp/wallet - name: Apply Liquibase Changes run: | cd db sql -S "${{ secrets.DB_USER }}/${{ secrets.DB_PASSWORD }}@${{ secrets.DB_SERVICE }}" <<'EOF' lb update -changelog-file controller.xml exit EOF env: TNS_ADMIN: /tmp/wallet ``` -------------------------------- ### Install SQLAlchemy and oracledb Source: https://github.com/oracle/skills/blob/main/db/frameworks/sqlalchemy-oracle.md Install the necessary libraries for SQLAlchemy and Oracle connectivity. ```bash pip install sqlalchemy oracledb ``` -------------------------------- ### Database-Only ORDS Install with Pre-written Config Source: https://github.com/oracle/skills/blob/main/db/ords/ords-installation.md Configure connection parameters first, then run the database installation phase only. Use for fresh installs requiring proxy user and passwords. ```shell ords --config /opt/oracle/ords/config config set db.hostname mydb.example.com ord --config /opt/oracle/ords/config config set db.port 1521 ord --config /opt/oracle/ords/config config set db.servicename mypdb.example.com # Fresh db-only install: include --proxy-user and provide both passwords ord --config /opt/oracle/ords/config install \ --db-pool default \ --db-only \ --admin-user "SYS AS SYSDBA" \ --proxy-user \ --password-stdin <` with a desired container name and `` with the specific image tag you pulled. Refer to the OCR README for exact environment variables, mounted volumes, and published ports. ```bash docker run --name --rm -it container-registry.oracle.com/database/graph-quickstart: ``` -------------------------------- ### Start Transaction Response Source: https://github.com/oracle/skills/blob/main/db/ords/ords-sessionless-transactions.md Example JSON response when starting a sessionless transaction, containing the global transaction identifier (GTRID). ```json { "gtrid": "25fd48199404437aa5faf33fe2b9fe0c", "status": "Start transaction" } ``` -------------------------------- ### Start ORDS Runtime Source: https://github.com/oracle/skills/blob/main/db/ords/ords-sample-app.md Starts the ORDS runtime server using a specified configuration OCID. This command assumes it's run from the ORDS installation directory. ```bash ./ords serve --ocid "$CONFIG_OCID" ``` -------------------------------- ### Example add_database.json Configuration Source: https://github.com/oracle/skills/blob/main/db/backup-recovery/cloud-protect.md Review the generated JSON configuration file for each discovered database. Key fields like dbUniqueName, compartmentId, protectionPolicy, sbtLibrary, oracleHome, oracleSid, and recoveryServiceSubnets must be verified. ```json [ { "dbUniqueName": "DB1", "displayName": "DB1", "compartmentId": "ocid1.compartment.oc1..example", "protectionPolicy": "ocid1.recoveryservicepolicy.oc1..example", "sbtLibrary": "/u01/app/oracle/product/19.27.0.0/dbhome_1/lib/libra.so", "oracleHome": "/u01/app/oracle/product/19.27.0.0/dbhome_1", "oracleSid": "DB1", "recoveryServiceSubnets": [ "ocid1.subnet.oc1.phx.example" ] } ] ``` -------------------------------- ### Install utPLSQL Framework Source: https://github.com/oracle/skills/blob/main/db/devops/database-testing.md Clone the utPLSQL repository and run the installation script to set up the framework in your Oracle database. Create a dedicated user for running tests and grant necessary privileges. ```shell git clone https://github.com/utPLSQL/utPLSQL.git cd utPLSQL sqlplus sys/password@//host:1521/service AS SYSDBA @install/install.sql sqlplus sys/password@//host:1521/service AS SYSDBA <<'EOF' CREATE USER ut_runner IDENTIFIED BY "password"; GRANT CREATE SESSION TO ut_runner; GRANT ut_runner TO ut_runner; -- utPLSQL role EOF ``` -------------------------------- ### Example Bearer Token Authentication Request Source: https://github.com/oracle/skills/blob/main/db/ords/ords-authentication.md This is an example HTTP GET request demonstrating how a client would send a JWT as a Bearer token in the Authorization header to authenticate with ORDS. ```http GET /ords/hr/v1/employees/ HTTP/1.1 Authorization: Bearer ``` -------------------------------- ### Define ORDS Handler for Collection Feed Source: https://github.com/oracle/skills/blob/main/db/ords/ords-metadata-catalog.md Use ORDS.DEFINE_HANDLER to define a specific REST operation (e.g., GET, POST) for a template. This example shows a GET handler for a collection feed, specifying the source SQL query. ```sql BEGIN ORDS.DEFINE_HANDLER( p_module_name => 'hr.employees', p_pattern => 'employees/', p_method => 'GET', p_source_type => ORDS.source_type_collection_feed, p_comments => 'Returns a paginated list of employees. Filter by department using ?dept_id=N. Supports ordering by any column.', p_source => 'SELECT * FROM employees' ); END; / ``` -------------------------------- ### Full ORDS URL Construction Example Source: https://github.com/oracle/skills/blob/main/db/ords/ords-architecture.md Demonstrates how the host, port, ORDS prefix, schema alias, module URI prefix, and template URI combine to form a complete URL. ```text https://host:port/ords/{schema_alias}/{module_uri_prefix}/{template_uri} │ │ │ │ │ hr (schema) api/v1/ employees/:id │ fixed ORDS prefix Result: `https://host:8443/ords/hr/api/v1/employees/101` ``` -------------------------------- ### Get DIFF Command Syntax Source: https://github.com/oracle/skills/blob/main/db/sqlcl/sqlcl-diff.md Use this command to check the installed SQLcl version or to understand the available options for the DIFF command. ```text help diff ``` -------------------------------- ### Cluster Verification Utility (CVU) Post-installation Checks Source: https://github.com/oracle/skills/blob/main/db/architecture/rac-concepts.md Execute post-installation checks with CVU after installing Grid Infrastructure. This command verifies the cluster setup and configuration. ```bash # Post-installation check # cluvfy stage -post crsinst -n node1,node2 ``` -------------------------------- ### Easy Connect Plus URL Examples Source: https://github.com/oracle/skills/blob/main/db/appdev/java-oracle-jdbc/connections.md Demonstrates Easy Connect Plus syntax for TCP/IP and TCPS connections, including parameters for timeouts, retries, load balancing, and TLS. ```text jdbc:oracle:thin:@//host[:port][/service_name] ``` ```text jdbc:oracle:thin:@//db-host.example.com:1521/sales jdbc:oracle:thin:@//db-host.example.com:1521/sales?connect_timeout=1min&transport_connect_timeout=30sec&retry_count=3&retry_delay=2 jdbc:oracle:thin:@//db1.example.com:1521,db2.example.com:1521/sales?load_balance=on&failover=on jdbc:oracle:thin:@tcps://db-host.example.com:1521/sales?tls_server_dn_match=on ``` -------------------------------- ### Initialize Sequelize CLI for Oracle Migrations Source: https://github.com/oracle/skills/blob/main/db/frameworks/sequelize-oracle.md Install the Sequelize CLI and initialize a new project for managing database migrations. ```bash npm install --save-dev sequelize-cli npx sequelize-cli init ``` -------------------------------- ### Basic EXECUTE IMMEDIATE Syntax Examples Source: https://github.com/oracle/skills/blob/main/db/sql-dev/dynamic-sql.md Demonstrates the basic syntax for executing DML, DDL, and queries with or without bind variables using EXECUTE IMMEDIATE. ```plsql EXECUTE IMMEDIATE 'CREATE TABLE temp_results (id NUMBER, result VARCHAR2(200))'; ``` ```plsql EXECUTE IMMEDIATE 'UPDATE employees SET salary = :1 WHERE employee_id = :2' USING p_new_salary, p_employee_id; ``` ```plsql EXECUTE IMMEDIATE 'SELECT last_name FROM employees WHERE employee_id = :1' INTO v_last_name USING p_employee_id; ``` ```plsql OPEN v_ref_cursor FOR 'SELECT employee_id, last_name FROM employees WHERE department_id = :1' USING p_dept_id; ``` -------------------------------- ### Get Session and Database Context Source: https://github.com/oracle/skills/blob/main/db/agent/schema-discovery.md Run this query at the start of a session to identify the current user, database name, container name, CDB name, and server host. ```sql -- 1. Who am I and what database am I connected to? SELECT SYS_CONTEXT('USERENV', 'SESSION_USER') AS current_user, SYS_CONTEXT('USERENV', 'DB_NAME') AS db_name, SYS_CONTEXT('USERENV', 'CON_NAME') AS container_name, SYS_CONTEXT('USERENV', 'CDB_NAME') AS cdb_name, SYS_CONTEXT('USERENV', 'SERVER_HOST') AS host FROM DUAL; ``` -------------------------------- ### Oracle Package and Procedures Example Source: https://github.com/oracle/skills/blob/main/db/migrations/migrate-db2-to-oracle.md Demonstrates creating an Oracle package to group related procedures and functions, including a procedure equivalent to the DB2 example. ```sql -- Oracle: group related procedures into a package CREATE OR REPLACE PACKAGE order_pkg AS PROCEDURE calculate_order_total( p_order_id IN NUMBER, p_total OUT NUMBER, p_item_count OUT NUMBER ); FUNCTION get_order_status(p_order_id IN NUMBER) RETURN VARCHAR2; END order_pkg; / CREATE OR REPLACE PACKAGE BODY order_pkg AS PROCEDURE calculate_order_total( p_order_id IN NUMBER, p_total OUT NUMBER, p_item_count OUT NUMBER ) AS BEGIN SELECT SUM(line_amount), COUNT(*) INTO p_total, p_item_count FROM order_lines WHERE order_id = p_order_id; IF p_total IS NULL THEN p_total := 0; p_item_count := 0; END IF; END calculate_order_total; FUNCTION get_order_status(p_order_id IN NUMBER) RETURN VARCHAR2 AS v_status VARCHAR2(20); BEGIN SELECT status INTO v_status FROM orders WHERE order_id = p_order_id; RETURN v_status; EXCEPTION WHEN NO_DATA_FOUND THEN RETURN 'NOT FOUND'; END get_order_status; END order_pkg; / ``` -------------------------------- ### Generated Downloads using source_type_media Source: https://github.com/oracle/skills/blob/main/db/ords/ords-file-upload-download.md This example demonstrates how to define a GET handler for generated downloads using `source_type_media`. It selects the content type and a PL/SQL function that renders the downloadable content. ```APIDOC ## GET employees/:employee_id/documents/:filename/download ### Description Handles generated file downloads by selecting the content type and the BLOB content from a PL/SQL function. ### Method GET ### Endpoint `/employees/:employee_id/documents/:filename/download` ### Parameters #### Path Parameters - **employee_id** (number) - Required - The ID of the employee. - **filename** (string) - Required - The name of the file to download. ### Request Example (No request body for GET) ### Response #### Success Response (200) - **content_type** (string) - The MIME type of the file. - **BLOB** - The binary content of the file. #### Response Example (Binary data stream for the file) ``` -------------------------------- ### Sample OpenAPI 3.0 Output for Employees API Source: https://github.com/oracle/skills/blob/main/db/ords/ords-metadata-catalog.md An example of the JSON output generated by ORDS for a simple GET /employees handler. This illustrates the structure and content of an OpenAPI 3.0 specification. ```json { "openapi": "3.0.0", "info": { "title": "HR REST API", "description": "Employee management API", "version": "1.0.0", "contact": { "name": "HR Platform Team" } }, "servers": [ { "url": "https://myserver.example.com/ords/hr/v1" } ], "paths": { "/employees/": { "get": { "summary": "List employees", "description": "Returns a paginated list of employees with optional filtering", "operationId": "getEmployees", "parameters": [ { "name": "offset", "in": "query", "schema": { "type": "integer", "default": 0 } }, { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 25 } }, { "name": "q", "in": "query", "description": "JSON filter query", "schema": { "type": "string" } } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/EmployeeCollection" } } } } } }, "post": { "summary": "Create new employee", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Employee" } } } }, "responses": { "201": { "description": "Employee created" } } } }, "/employees/{id}": { "get": { "summary": "Get employee by ID", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Employee found" }, "404": { "description": "Employee not found" } } } } }, "components": { "schemas": { "Employee": { "type": "object", "properties": { "employee_id": { "type": "integer" }, "first_name": { "type": "string" }, "last_name": { "type": "string" }, "email": { "type": "string" }, "salary": { "type": "number" } } } }, "securitySchemes": { "OAuth2": { "type": "oauth2", "flows": { "clientCredentials": { "tokenUrl": "https://myserver.example.com/ords/hr/oauth/token", "scopes": { "hr.employees.read": "Read employee data" } } } } } } } ``` -------------------------------- ### Dependency Injection Setup for Dapper with Oracle Source: https://github.com/oracle/skills/blob/main/db/frameworks/dapper-oracle.md Provides an example of configuring Dapper with Oracle for dependency injection in an ASP.NET Core application. Register `IDbConnection` with `OracleConnection` in `Program.cs` and inject it into repositories. ```csharp // Program.cs builder.Services.AddScoped(_ => new OracleConnection(builder.Configuration.GetConnectionString("OracleDb"))); // appsettings.json { "ConnectionStrings": { "OracleDb": "User Id=hr;Password=password;Data Source=localhost:1521/freepdb1;" } } // EmployeeRepository.cs public class EmployeeRepository { private readonly IDbConnection _conn; public EmployeeRepository(IDbConnection conn) => _conn = conn; public Task> GetByDeptAsync(int deptId) => _conn.QueryAsync( "SELECT employee_id AS EmployeeId, last_name AS LastName " + "FROM employees WHERE department_id = :dept", new { dept = deptId }); } ``` -------------------------------- ### CREATE SEQUENCE Basic Examples Source: https://github.com/oracle/skills/blob/main/db/appdev/sequences-identity.md Illustrates common patterns for creating sequences, including a standard primary key sequence, a descending sequence, and a sequence for generating even numbers. ```sql -- Simple primary key sequence (most common pattern) CREATE SEQUENCE seq_customer_id START WITH 1000 INCREMENT BY 1 MAXVALUE 9999999999 NOCYCLE CACHE 100; ``` ```sql -- Descending sequence CREATE SEQUENCE seq_priority_desc START WITH 10000 INCREMENT BY -1 MINVALUE 1 NOCYCLE CACHE 50; ``` ```sql -- Step sequence for generating even numbers CREATE SEQUENCE seq_even_numbers START WITH 2 INCREMENT BY 2 MAXVALUE 1000000 NOCYCLE CACHE 20; ``` -------------------------------- ### Complete Property Graph Creation Example Source: https://github.com/oracle/skills/blob/main/db/appdev/sql-property-graph.md An example demonstrating the creation of a property graph named 'students_graph', defining vertex tables 'persons' and 'university', and edge tables 'friends' and 'student_of' with their respective keys, labels, and properties. ```sql CREATE OR REPLACE PROPERTY GRAPH students_graph VERTEX TABLES ( persons KEY (person_id) LABEL person PROPERTIES (person_id, name, birthdate AS dob) LABEL person_ht PROPERTIES (height), university KEY (id) ) EDGE TABLES ( friends KEY (friendship_id) SOURCE KEY (person_a) REFERENCES persons(person_id) DESTINATION KEY (person_b) REFERENCES persons(person_id) PROPERTIES (friendship_id, meeting_date), student_of KEY (s_id) SOURCE KEY (s_person_id) REFERENCES persons(person_id) DESTINATION KEY (s_univ_id) REFERENCES university(id) PROPERTIES (subject) ); ``` -------------------------------- ### Initiate Guided OKE Node Pool Creation Source: https://github.com/oracle/skills/blob/main/oci/oke/gva-node-pools.md Use this command to start the interactive GVA node-pool workflow. It prompts for input, generates an OCI CLI command, and requires explicit approval before execution. ```bash bash oci/oke/scripts/gva-menu.sh ``` -------------------------------- ### Nginx Configuration for ORDS Behind Reverse Proxy Source: https://github.com/oracle/skills/blob/main/db/ords/ords-installation.md Example Nginx configuration to proxy requests to an ORDS instance running on HTTP internally. This setup terminates TLS at the proxy level, recommended for production environments. ```nginx # /etc/nginx/conf.d/ords.conf server { listen 443 ssl; server_name api.mycompany.com; ssl_certificate /etc/ssl/certs/mycompany.crt; ssl_certificate_key /etc/ssl/private/mycompany.key; ssl_protocols TLSv1.2 TLSv1.3; location /ords/ { proxy_pass http://localhost:8080/ords/; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto https; proxy_read_timeout 300; proxy_send_timeout 300; } } ``` -------------------------------- ### Display Help Information Source: https://github.com/oracle/skills/blob/main/db/sqlcl/sqlcl-basics.md Use the HELP command to view available commands and their syntax. You can get help for specific commands by appending their name. ```sql HELP HELP INDEX HELP SET HELP SPOOL HELP CONNECT ``` -------------------------------- ### Liquibase Project Structure Example Source: https://github.com/oracle/skills/blob/main/db/devops/schema-migrations.md Illustrates a recommended directory structure for organizing Liquibase migration files, separating changesets by object type and including stored procedures and seed data. ```directory db/ liquibase.properties changelog-root.xml changes/ 001-initial-schema.xml 002-add-customer-status.xml 003-orders-partitioning.xml procedures/ pkg_orders_body.sql pkg_orders_spec.sql seeds/ 001-reference-data.xml ``` -------------------------------- ### Master Install Script for Oracle Schema Source: https://github.com/oracle/skills/blob/main/db/devops/version-control-sql.md This script recreates the entire schema from scratch in the correct dependency order. It is used for new environment provisioning and CI database container setup. Ensure you run this as a DBA or schema owner with CREATE privileges. ```sql -- schema/install.sql -- Creates all schema objects in dependency order. -- Run as DBA or schema owner with CREATE privileges. -- Usage: sqlplus user/pass@//host:1521/service @install.sql WHENEVER SQLERROR EXIT FAILURE ROLLBACK -- Types (no dependencies) @@types/typ_order_line.sql @@types/typ_order_line_tbl.sql -- Sequences (no dependencies) @@sequences/seq_customer_id.sql @@sequences/seq_order_id.sql @@sequences/seq_invoice_id.sql -- Tables (in FK dependency order) @@tables/customers.sql @@tables/customer_status_codes.sql @@tables/products.sql @@tables/product_categories.sql @@tables/orders.sql @@tables/order_lines.sql @@tables/invoices.sql -- Indexes @@indexes/idx_orders_customer.sql @@indexes/idx_orders_status.sql @@indexes/idx_customers_email.sql @@indexes/idx_order_lines_order.sql -- Views (depend on tables) @@views/vw_active_customers.sql @@views/vw_order_summary.sql @@views/vw_invoice_detail.sql -- Package specs (can depend on types, sequences) @@packages/pkg_customers.pks @@packages/pkg_orders.pks @@packages/pkg_invoicing.pks -- Package bodies (depend on specs) @@packages/pkg_customers.pkb @@packages/pkg_orders.pkb @@packages/pkg_invoicing.pkb -- Standalone procedures and functions @@procedures/prc_archive_old_orders.sql @@functions/fnc_calculate_tax.sql -- Triggers (depend on tables and sometimes packages) @@triggers/trg_customers_bi.sql @@triggers/trg_orders_bi.sql @@triggers/trg_orders_audit.sql -- Grants (depend on all objects existing) @@grants/grants_to_app_user.sql @@grants/grants_to_report_user.sql -- Synonyms (depend on grants) @@synonyms/public_synonyms.sql PROMPT Schema installation complete. ``` -------------------------------- ### Install SQLcl on macOS using Homebrew Source: https://github.com/oracle/skills/blob/main/db/sqlcl/sqlcl-basics.md Use this command to install SQLcl on macOS via Homebrew. The command is available as `sql` after installation. ```shell brew install sqlcl ``` -------------------------------- ### Create Composite Index and Query Examples Source: https://github.com/oracle/skills/blob/main/db/performance/index-strategy.md Demonstrates creating a composite index on two columns and shows how different query predicates utilize the index. The leading column must be present for efficient index access. ```sql -- Index on (DEPT_ID, SALARY) CREATE INDEX emp_dept_sal_ix ON employees (department_id, salary); ``` ```sql -- Uses the index (leading column in predicate) SELECT * FROM employees WHERE department_id = 50 AND salary > 5000; -- Access: INDEX RANGE SCAN on department_id=50, filter salary>5000 ``` ```sql -- Uses the index (leading column only) SELECT * FROM employees WHERE department_id = 50; -- Access: INDEX RANGE SCAN ``` ```sql -- Does NOT use the index efficiently (leading column absent) SELECT * FROM employees WHERE salary > 5000; -- Access: INDEX SKIP SCAN or TABLE ACCESS FULL (depends on cardinality) ``` ```sql -- Column order matters for range predicates: -- Index (DEPT_ID, HIRE_DATE) — good for: WHERE dept=X AND hire_date BETWEEN... -- Index (HIRE_DATE, DEPT_ID) — good for: WHERE hire_date=X AND dept=Y -- but cannot efficiently range-scan HIRE_DATE if DEPT_ID is not equality ``` -------------------------------- ### Install python-oracledb Source: https://github.com/oracle/skills/blob/main/db/appdev/python-oracledb.md Install the python-oracledb package using pip. ```bash pip install oracledb ``` -------------------------------- ### Create and Install Application Container Source: https://github.com/oracle/skills/blob/main/db/architecture/multitenant.md Use this SQL script to create a new application container and install an application within it. Ensure you are connected to CDB$ROOT for the initial creation. ```sql -- Step 1: Create the Application Container in CDB$ROOT ALTER SESSION SET CONTAINER = CDB$ROOT; CREATE PLUGGABLE DATABASE saas_app_root AS APPLICATION CONTAINER ADMIN USER saas_admin IDENTIFIED BY "SaasAdmin#1" FILE_NAME_CONVERT = ('/oradata/MYDB/pdbseed/', '/oradata/MYDB/saas_app_root/'); ALTER PLUGGABLE DATABASE saas_app_root OPEN; -- Step 2: Connect to the Application Container and install the application ALTER SESSION SET CONTAINER = saas_app_root; ALTER PLUGGABLE DATABASE APPLICATION saas_crm BEGIN INSTALL '1.0'; -- Create shared application objects (visible to all app PDBs) CREATE TABLE app_config ( config_key VARCHAR2(100) NOT NULL, config_value VARCHAR2(4000), CONSTRAINT pk_app_config PRIMARY KEY (config_key) ) SHARING = DATA; -- DATA sharing: metadata AND rows shared CREATE TABLE product_catalog ( product_id NUMBER NOT NULL, product_name VARCHAR2(200) NOT NULL, CONSTRAINT pk_product PRIMARY KEY (product_id) ) SHARING = EXTENDED DATA; -- EXTENDED DATA: shared rows + tenants can add their own ALTER PLUGGABLE DATABASE APPLICATION saas_crm END INSTALL '1.0'; ``` -------------------------------- ### Install node-oracledb Source: https://github.com/oracle/skills/blob/main/db/appdev/nodejs-oracledb.md Install the node-oracledb package using npm. ```bash npm install oracledb ``` -------------------------------- ### Create and Verify B-Tree Indexes Source: https://github.com/oracle/skills/blob/main/db/performance/index-strategy.md Demonstrates creating simple, unique B-tree indexes and verifying their properties and indexed columns. ```sql -- Simple B-tree index CREATE INDEX emp_salary_ix ON employees (salary); ``` ```sql -- Unique B-tree index (enforces uniqueness and enables UNIQUE SCAN) CREATE UNIQUE INDEX emp_email_uk ON employees (email); ``` ```sql -- Verify index was created SELECT index_name, index_type, uniqueness, status FROM user_indexes WHERE table_name = 'EMPLOYEES'; ``` ```sql -- See indexed columns SELECT index_name, column_position, column_name, descend FROM user_ind_columns WHERE table_name = 'EMPLOYEES' ORDER BY index_name, column_position; ``` -------------------------------- ### Setting Up AI Provider Credentials and Profile Source: https://github.com/oracle/skills/blob/main/db/features/select-ai.md Before using Select AI, create credentials for your AI provider and an AI profile. The profile specifies the provider, credential, and relevant database objects. Ensure the profile is set for the current session. ```sql BEGIN DBMS_CLOUD.CREATE_CREDENTIAL( credential_name => 'OPENAI_CRED', username => 'OPENAI', password => 'sk-...' -- your API key ); END; / -- 2. Create an AI profile BEGIN DBMS_CLOUD_AI.CREATE_PROFILE( profile_name => 'MY_AI_PROFILE', attributes => '{"provider": "openai", "credential_name": "OPENAI_CRED", "object_list": [{"owner": "HR", "name": "EMPLOYEES"}, {"owner": "HR", "name": "DEPARTMENTS"}], "comments": true, "temperature": 0}' ); END; / -- 3. Set the profile for the current session EXEC DBMS_CLOUD_AI.SET_PROFILE('MY_AI_PROFILE'); ``` -------------------------------- ### Dynamic LOV SQL Example Source: https://github.com/oracle/skills/blob/main/apex/apexlang/references/policies/memory-bank/40-components/apex.items.md This is an example of SQL for a dynamic LOV. The SQL must be provided as a triple-backticked multi-line string, and it should project deterministic display and return aliases. ```sql select deptno as value, dname as display from dept order by dname ``` -------------------------------- ### Basic `rcv` Command Structure Source: https://github.com/oracle/skills/blob/main/db/backup-recovery/cloud-protect.md This is the general syntax for using the `rcv` command. Use `help` to discover available actions and objects. ```sql SQL> rcv [options] ``` ```sql SQL> help rcv ``` ```sql SQL> rcv show database ``` ```sql SQL> rcv show restore_range ``` ```sql SQL> rcv backup database ``` ```sql SQL> rcv run checks ``` -------------------------------- ### Invalid Generation Plan Example Source: https://github.com/oracle/skills/blob/main/apex/apexlang/references/workflows/apexlang/prompt-contracts.md An example of an invalid, incomplete Generation Plan. ```text Draft page 12 ( ... ``` -------------------------------- ### Prepare and Exchange Partition with Staging Table Source: https://github.com/oracle/skills/blob/main/db/design/partitioning-strategy.md Demonstrates the zero-copy ETL process by exchanging a table partition with a staging table that has an identical structure but is not partitioned. ```sql -- 1. Create staging table with identical structure (no partitioning) CREATE TABLE SALES_STAGING FOR EXCHANGE WITH SALES; ``` ```sql -- 2. Load data into staging table (bulk insert, external table, etc.) INSERT /*+ APPEND */ INTO SALES_STAGING SELECT ...; COMMIT; ``` ```sql -- 3. Exchange: swap partition with staging table atomically ALTER TABLE SALES EXCHANGE PARTITION p_2024_q4 WITH TABLE SALES_STAGING INCLUDING INDEXES WITHOUT VALIDATION; -- skip row validation for performance ``` -------------------------------- ### Install ODP.NET Managed Driver Source: https://github.com/oracle/skills/blob/main/db/appdev/dotnet-oracle.md Install the Oracle Managed Data Access driver using NuGet. This is the recommended driver for most scenarios as it's pure .NET and doesn't require an Oracle Client installation. ```bash dotnet add package Oracle.ManagedDataAccess.Core ``` ```bash dotnet add package Oracle.EntityFrameworkCore ``` -------------------------------- ### Start and Check Daemon Status Source: https://github.com/oracle/skills/blob/main/db/sqlcl/sqlcl-scheduler-daemon.md Commands to start the SQLcl daemon and then check its current status. ```shell sql -daemon start sql -daemon status ``` -------------------------------- ### Install Pandas, SQLAlchemy, and OracleDB Source: https://github.com/oracle/skills/blob/main/db/frameworks/pandas-oracle.md Install the necessary libraries for Pandas to interact with Oracle Database. ```bash pip install pandas sqlalchemy oracledb ``` -------------------------------- ### Verify SQLcl Installation Source: https://github.com/oracle/skills/blob/main/db/sqlcl/sqlcl-basics.md Run this command to verify that SQLcl has been installed correctly and is accessible from your command line. ```shell sql -V ``` -------------------------------- ### Configure Main Entry Point Source: https://github.com/oracle/skills/blob/main/graal/native-image/native-build-tools.md Specify the main class to be used as the entry point for the native executable. ```groovy mainClass = 'com.example.Main' ``` -------------------------------- ### Install Claude Code GraalVM Domain Plugin Source: https://github.com/oracle/skills/blob/main/README.md Installs the GraalVM domain plugin from the registered marketplace. ```bash /plugin install graal@oracle-skills ``` -------------------------------- ### Teradata BTEQ Session Example Source: https://github.com/oracle/skills/blob/main/db/migrations/migrate-teradata-to-oracle.md Demonstrates a typical Teradata BTEQ session including logging on, setting session parameters, executing queries, and logging off. ```sql -- Teradata BTEQ session .LOGON myhost/myuser,mypassword; .SET WIDTH 200; .SET TITLEDASHES OFF; SEL * FROM customers WHERE cust_id = 12345; SEL COUNT(*) FROM orders; -- Insert using SEL INSERT INTO archive_orders SEL * FROM orders WHERE order_date < '2020-01-01' (DATE); .LOGOFF; .QUIT; ``` -------------------------------- ### Easy Connect Examples Source: https://github.com/oracle/skills/blob/main/db/appdev/connection-pooling.md Various examples of Easy Connect strings, including one with DRCP enabled. ```text db-host/ORCL ``` ```text db-host:1521/MYSERVICE ``` ```text db-host:1521/MYSERVICE:POOLED ``` ```text scan-host:1521/MYSERVICE ``` -------------------------------- ### View SET DDL Settings Help Source: https://github.com/oracle/skills/blob/main/db/sqlcl/sqlcl-ddl-generation.md Provides instructions on how to access the help documentation for all available `SET DDL` settings within SQLcl. ```sql HELP SET DDL ```