WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Oracle Database · Basic · question 15 of 100

How do you create a simple table in Oracle SQL using the CREATE TABLE statement?

📕 Buy this interview preparation book: 100 Oracle Database questions & answers — PDF + EPUB for $5

To create a simple table in Oracle SQL, we can use the CREATE TABLE statement. The basic syntax for the CREATE TABLE statement is as follows:

CREATE TABLE table_name (
    column1 datatype,
    column2 datatype,
    ...
);

Each column is defined with a data type and we can also specify any constraints on the column, such as NOT NULL, UNIQUE, or PRIMARY KEY. Here is an example of a simple table creation:

CREATE TABLE employees (
   employee_id   NUMBER(5) PRIMARY KEY,
   first_name    VARCHAR2(50),
   last_name     VARCHAR2(50),
   email         VARCHAR2(100) UNIQUE,
   hire_date     DATE,
   job_title     VARCHAR2(50),
   salary        NUMBER(10,2)
);

In this example, we created a table called "employees" with six columns: employee_id, first_name, last_name, email, hire_date, job_title, and salary.

The employee_id column is defined with the NUMBER data type and is also defined as the primary key of the table. The first_name, last_name, and job_title columns are defined as VARCHAR2 data type with a maximum length of 50 characters. The email column is also defined as a VARCHAR2 data type but has the UNIQUE constraint, meaning that each value in this column must be unique. The hire_date column is defined with the DATE data type, while the salary column is defined as a NUMBER data type with a maximum of 10 digits, including 2 decimal places.

By executing this SQL statement, the employees table will be created in the Oracle database ready to store data. We can then insert rows of data into the table using the INSERT INTO statement, or we can modify it using the ALTER or DROP commands.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Oracle Database interview — then scores it.
📞 Practice Oracle Database — free 15 min
📕 Buy this interview preparation book: 100 Oracle Database questions & answers — PDF + EPUB for $5

All 100 Oracle Database questions · All topics