TABLE
TABLE in SQL refers to an organized structure for storing data. It is composed of rows and columns where each row represents a record and each column represents a field of that record. The intersecting point of a row and a column in a table represents a cell. Information is stored efficiently and accessibly in an SQL table, making it an integral part of RDBMS (Relational Database Management Systems).
Example
Output
Explanation
This SQL statement creates a new table named ‘Employee’. The table includes columns for ID, Name, Age, and Salary. The ID column is designated as the primary key.
Example
Output
‘CREATE TABLE’ command is successfully executed
Explanation
This SQL statement creates a new table in a database. The table, named ‘Employees’, has four fields: ‘ID’, ‘NAME’, ‘SALARY’, and ‘JOIN_DATE’. The ‘ID’ field is of type INT and is the primary key, the ‘NAME’ field is of type TEXT, the ‘SALARY’ field is of type REAL with a default value of 30000.0, and the ‘JOIN_DATE’ field is of type DATE.
Example
Output
Explanation
The above example creates a table called Employees
with columns ID
, FirstName
, LastName
, and Position
. It then inserts a record into the table, with the ID of 1, first name of ‘John’, last name of ‘Doe’, and position of ‘Manager’.
Example
Output
Explanation
The above SQL statement is an example of how to create a new table in Oracle called Employees. The table is composed of five columns, Employee_Id
, First_Name
, Last_Name
, Hire_Date
and Phone_Number
. Each column has a specific data type and size - number(10)
for Employee_Id, varchar2(100)
for First_Name and Last_Name, date
for Hire_Date and varchar2(20)
for Phone_Number.
Example
Output
Explanation
The CREATE TABLE
statement is used to create a new table called Students
with four columns: ID
, Name
, Age
, and Grade
. ID
is assigned as the primary key. The NOT NULL
constraint ensures that each of these columns must always have a value.
The INSERT INTO
statement is used to insert two new rows of values into the Students
table.
Finally, the SELECT * FROM Students
statement selects all rows and columns from the Students
table, displaying all the data contained within the table.