Select all the data from the Employees database. The select query statement offers the retrieval of stored data in a database table. The syntax using the SELECT statement:
Select * from employees;
Note: Using the (*) indicates that you would like to retrieve all of the records stored in the employees
Table.
The Select statement in combination with the where clause can also be used to filter specific records. We may be interest in retrieving the data stored for the employee_id equal to 1. The syntax using the SELECT statement with the WHERE clause:
Select * from employees where employee_id = '1';
Insert a new record into the employees table. Using the DESCRIBE command will supply a employee table structure. For example, at the SQL prompt, enter "describe employees;" the results will list the Name of the columns, Null? - value information; indicating that you must supply a value for the column, and the type of column, numeric, date or character.
Name
---------
EMPLOYEE_ID
MANAGER_ID
FIRST_NAME
LAST_NAME
TITLE
SALARY
Null?
------
NOT NULL
-------
NOT NULL
NOT NULL
------
------
Type
------
NUMBER(38)
NUMBER(38)
VARCHAR2(10)
VARCHAR2(10)
VARCHAR2(20)
NUMBER(6)
The syntax used for the insert command is
INSERT INTO employees (
employee_id, manager_id, first_name, last_name, title, salary)
VALUES (3, 1, 'Joan', 'Johnson', 'Manager', 50000) ;
Update an employee's record. The update statement is a data manipulation statement that allows you to change the data in a row. The syntax used for the update statement with the SET and WHERE clauses:
UPDATE employees
SET salary = 55000
WHERE employee_id = 3;
Delete an employee's record. The delete statement is a data manipulation statement that allows you to delete the data in a row. The syntax used for the delete statement with the WHERE clause:
DELETE FROM employees
WHERE employee_id = 3;
0 comments:
Post a Comment