Convert Figma logo to code with AI

oracle-samples logooracle-db-examples

Examples of applications and tool usage for Oracle Database

1,300
829
1,300
27

Top Related Projects

Azure Data SQL Samples - Official Microsoft GitHub Repository containing code samples for SQL Server, Azure SQL, Azure Synapse, and Azure SQL Edge

15,716

Mirror of the official PostgreSQL GIT repository. Note that this is just a *mirror* - we don't work with pull requests on github. To contribute, please see https://wiki.postgresql.org/wiki/Submitting_a_Patch

26,065

The MongoDB Database

Quick Overview

The oracle-samples/oracle-db-examples repository is a comprehensive collection of code samples and tutorials for Oracle Database technologies. It covers a wide range of topics including SQL, PL/SQL, Java, Python, and various Oracle-specific features. This repository serves as a valuable resource for developers working with Oracle databases, providing practical examples and best practices.

Pros

  • Extensive coverage of Oracle Database technologies and features
  • Well-organized structure with examples for multiple programming languages
  • Regularly updated with new examples and improvements
  • Official repository maintained by Oracle, ensuring accuracy and relevance

Cons

  • Some examples may be specific to certain Oracle Database versions
  • Requires basic knowledge of Oracle Database concepts to fully utilize
  • Limited community contributions compared to open-source projects
  • Some advanced topics may lack in-depth explanations

Code Examples

  1. Connecting to Oracle Database using Python and cx_Oracle:
import cx_Oracle

# Connect to Oracle Database
connection = cx_Oracle.connect("username", "password", "localhost/orclpdb")

# Create a cursor
cursor = connection.cursor()

# Execute a query
cursor.execute("SELECT * FROM employees")

# Fetch and print results
for row in cursor:
    print(row)

# Close the cursor and connection
cursor.close()
connection.close()
  1. Creating a simple PL/SQL procedure:
CREATE OR REPLACE PROCEDURE greet_user(p_name IN VARCHAR2) IS
BEGIN
  DBMS_OUTPUT.PUT_LINE('Hello, ' || p_name || '!');
END;
/

-- Execute the procedure
BEGIN
  greet_user('John');
END;
/
  1. Using Oracle JSON features:
-- Create a table with JSON column
CREATE TABLE customers (
  id NUMBER PRIMARY KEY,
  data JSON
);

-- Insert JSON data
INSERT INTO customers VALUES (
  1,
  '{"name": "Alice", "age": 30, "city": "New York"}'
);

-- Query JSON data
SELECT c.data.name, c.data.age
FROM customers c
WHERE c.data.city = 'New York';

Getting Started

To get started with the Oracle Database examples:

  1. Clone the repository:

    git clone https://github.com/oracle-samples/oracle-db-examples.git
    
  2. Navigate to the desired example directory:

    cd oracle-db-examples/python
    
  3. Follow the README instructions in each subdirectory for specific setup and execution steps.

  4. Ensure you have the necessary Oracle Database software and client libraries installed on your system.

  5. Run the examples and modify them as needed for your specific use case.

Competitor Comparisons

Azure Data SQL Samples - Official Microsoft GitHub Repository containing code samples for SQL Server, Azure SQL, Azure Synapse, and Azure SQL Edge

Pros of sql-server-samples

  • More comprehensive coverage of SQL Server features and scenarios
  • Better organization with clear categorization of samples
  • Includes samples for various SQL Server versions and tools

Cons of sql-server-samples

  • Less focus on performance optimization techniques
  • Fewer examples of advanced database administration tasks
  • Limited coverage of cloud-specific features compared to Oracle's examples

Code Comparison

sql-server-samples:

CREATE PROCEDURE dbo.usp_GetEmployeeManagers
    @EmployeeID INT
AS
BEGIN
    WITH EmpCTE AS (
        SELECT EmployeeID, ManagerID, FirstName, LastName
        FROM HumanResources.Employee
        WHERE EmployeeID = @EmployeeID
        UNION ALL
        SELECT e.EmployeeID, e.ManagerID, e.FirstName, e.LastName
        FROM HumanResources.Employee e
        INNER JOIN EmpCTE ecte ON ecte.ManagerID = e.EmployeeID
    )
    SELECT EmployeeID, FirstName, LastName
    FROM EmpCTE
END

oracle-db-examples:

CREATE OR REPLACE PROCEDURE get_employee_managers(
    p_employee_id IN NUMBER
) AS
BEGIN
    FOR rec IN (
        SELECT employee_id, first_name, last_name
        FROM employees
        START WITH employee_id = p_employee_id
        CONNECT BY PRIOR manager_id = employee_id
    ) LOOP
        DBMS_OUTPUT.PUT_LINE(rec.employee_id || ' ' || rec.first_name || ' ' || rec.last_name);
    END LOOP;
END;
/
15,716

Mirror of the official PostgreSQL GIT repository. Note that this is just a *mirror* - we don't work with pull requests on github. To contribute, please see https://wiki.postgresql.org/wiki/Submitting_a_Patch

Pros of postgres

  • Open-source and community-driven development
  • More extensive codebase with full database engine implementation
  • Active and frequent contributions from a diverse developer base

Cons of postgres

  • Steeper learning curve for contributors due to larger codebase
  • Less focused on providing specific examples for users
  • May require more setup and configuration for testing and development

Code Comparison

postgres:

/* in src/backend/access/heap/heapam.c */
HeapTuple
heap_fetch(Relation relation, Buffer buffer, ItemPointer tid,
           SnapshotData *snapshot, bool *all_dead)
{
    Page		page;
    ItemId		lp;
    HeapTupleData	tuple;

oracle-db-examples:

-- in sql/analytical-sql-examples/row_pattern_matching/01_basic.sql
SELECT *
FROM Ticker MATCH_RECOGNIZE (
  PARTITION BY symbol
  ORDER BY tstamp
  MEASURES STRT.tstamp AS start_tstamp,
           LAST(DOWN.tstamp) AS bottom_tstamp,
           LAST(UP.tstamp) AS end_tstamp

The postgres repository contains the full database engine implementation in C, while oracle-db-examples focuses on SQL examples and use cases. postgres offers a comprehensive look into database internals, whereas oracle-db-examples provides practical SQL patterns for Oracle Database users.

26,065

The MongoDB Database

Pros of mongo

  • Open-source project with a large community of contributors
  • Flexible document-based data model for easier schema evolution
  • Native support for horizontal scaling and sharding

Cons of mongo

  • Less mature and feature-rich compared to Oracle's enterprise-grade offerings
  • Limited support for complex transactions and joins
  • Potential performance issues with large datasets and complex queries

Code Comparison

mongo:

db.users.insertOne({
  name: "John Doe",
  age: 30,
  email: "john@example.com"
})

oracle-db-examples:

INSERT INTO users (name, age, email)
VALUES ('John Doe', 30, 'john@example.com');

The mongo example demonstrates its flexible document structure, allowing for easy insertion of nested data without predefined schemas. The oracle-db-examples snippet showcases the traditional SQL syntax for inserting data into a relational database.

While mongo offers simplicity and flexibility, oracle-db-examples provides a more structured approach with stronger data consistency guarantees. The choice between the two depends on specific project requirements, scalability needs, and the development team's expertise.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

oracle-db-examples

This repository stores a variety of examples demonstrating how to use the Oracle Database.

Repo/Folder nameDescription
CC examples
apexAPEX examples
db-sample-schemasGit submodule of the Oracle Database Sample Schemas
dotnet.NET based examples
exadataExadata examples
javaJava examples
javascriptJavaScript examples
machine-learningOracle Machine Learning examples
optimizerOracle Optmizer and Optimizer Stats examples
plsqlPL/SQL examples
pythonPython examples
rubyRuby examples
sagasSaga examples
securitySecurity features examples
spatialSpatial features examples
sqlSQL examples
sqldeveloperSQL Developer examples
txeventqTxEventQ examples

Documentation

You can find the online documentation of the Oracle Database under docs.oracle.com/en/database/

LiveSQL

Some of the examples that you see within this repository can be executed in the free web-based tool: LiveSQL.oracle.com.

LiveSQL is also an excellent resource for getting started with Oracle Database.

Dev Gym

If you would like to challenge yourself, you can take quizzes, workouts and classes at DevGym.oracle.com.

Contributing

This project welcomes contributions from the community. Before submitting a pull request, please review our contribution guide

Security

Please consult the security guide for our responsible security vulnerability disclosure process

License

You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.")

You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced in LICENSE.md

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and limitations under the License.