How to Create Oracle Table Using dotConnect for Oracle

This tutorial describes how to create tables, stored procedures and other objects on Oracle server. The tutorial consists of the following sections:

Download Now dotConnect for Oracle

Requirements

In order to create database objects you have to connect to server. This process is described in details in the tutorial on how to connect to Oracle database.

General information

Database objects are created using Data Definition Language (DDL), which is a part of SQL. The DDL statements can be executed on server by account that has necessary privileges.

There are two ways to manipulate a database. You can build DDL statements manually and run them within Oracle SQL*Plus or a component like OracleCommand. Another way is to use IDE - visual shells that provide graphical user interface to manage database. We will discuss both ways.

Using SQL*Plus

  1. Launch the SQL*Plus and authorize yourself.

  2. Type:

    CREATE TABLE dept (
      deptno INT PRIMARY KEY,
      dname VARCHAR(14),
      loc VARCHAR(13)
    )
    /
    

    Press Enter. This will create first of the tables we'll use for tutorial purposes.

  3. Run the following query:

    CREATE TABLE emp (
      empno INT PRIMARY KEY,
      ename VARCHAR(10),
      job VARCHAR(9),
      mgr INT,
      hiredate DATE,
      sal FLOAT,
      comm FLOAT,
      deptno INT REFERENCES dept
    )
    /
    
  4. These two tables are enough to demonstrate basic functionality. Now you can type exit to exit the SQL*Plus.

Using dbForge Fusion for Oracle

Things are much simpler when you control them visually. The same statements can be executed without writing a line of code. This section describes how to manipulate database objects visually in dbForge Fusion for Oracle.

  1. Open the Database Explorer toolwindow if it is not open yet. To do this, in View menu point to Devart Developer Tools, and then click Database Explorer item.
  2. Click on the New Connection button on Database Explorer or the toolbar.
  3. In the Database Connection Properties dialog specify connection parameters and click OK.
  4. Right-click on Tables node.
  5. Choose New Table from popup menu.
  6. Input name of the table: dept, press OK.
  7. In Table menu, choose New Column.
  8. In the Column Editor describe first column and press OK.
  9. Repeat steps 7 and 8 for every column in the table.
  10. Press Ctrl+S to save the document. The table will be created in the database.

Note that dbForge Fusion for Oracle has its own comprehensive documentation with tutorials.

Conclusion

This article describes creating Oracle tables that are used in other tutorials for dotConnect for Oracle, a high-performance ADO.NET provider from Devart with ORM support.

There are more ways to create tables on an Oracle server. Any tool or component that is capable of running a SQL query, can be used to manage database objects. For example, such dotConnect for Oracle class as OracleCommand suits fine for creating objects one by one, while OracleScript is designed for executing series of DDL/DML statements. For information on DDL statements syntax refer to Oracle documentation.


Back to list

dotConnect for Oracle

Get enhanced ORM-enabled data provider for Oracle and develop .NET applications working with Oracle data quickly and easily!