How to create table in oracle?

by filiberto , in category: MySQL , a month ago

How to create table in oracle?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by dana , a month ago

@filiberto 

To create a table in Oracle, you can use the following SQL command:

1
2
3
4
5
6
CREATE TABLE table_name (
    column1 datatype [constraint],
    column2 datatype [constraint],
    ...
    columnN datatype [constraint]
);


Here's an example of creating a simple table named "employees" with columns for employee id, name, and department:

1
2
3
4
5
CREATE TABLE employees (
    employee_id INT PRIMARY KEY,
    name VARCHAR(50),
    department VARCHAR(50)
);


In this example, the table "employees" is created with three columns: employee_id, name, and department, each with their own data types. The employee_id column is designated as the primary key using the 'PRIMARY KEY' constraint.


You can add additional constraints such as NOT NULL, UNIQUE, FOREIGN KEY, etc., to ensure data integrity in your table.


Remember to replace "table_name" with the desired name for your table and define the appropriate column names and data types based on your requirements.