Creating Tables in Oracle
Tables are the basic building blocks of any database. They are used to store data in rows and columns. In Oracle Database, you can create tables using the CREATE TABLE statement. Here is an example:
CREATE TABLE employees (
employee_id NUMBER(5) PRIMARY KEY,
first_name VARCHAR2(20),
last_name VARCHAR2(25),
email VARCHAR2(25),
hire_date DATE DEFAULT sysdate,
job_id VARCHAR2(10),
salary NUMBER(8,2),
commission_pct NUMBER(2,2),
manager_id NUMBER(5)
);
This creates a table named "employees" with several columns. The employee_id column is designated as the primary key, which means that it will contain unique values for each row in the table. The hire_date column has a default value of the current date and time (sysdate), which will be used if a value is not provided during insertion. The other columns are defined with their data types and sizes.
No comments:
Post a Comment