Documente Academic
Documente Profesional
Documente Cultură
TIMESTAMP VARIATIONS -is an extension of the DATE data type. It stores the year,
month and day of the DATE datatype, plus hour, minute, seconds and fractional second values. CREATE TABLE new_table (employee_id NUMBER(5), first_name VARCHAR2(10), ... start_date TIMESTAMP(7)); DD-MON-YY 12.00.00.000000 start_date TIMESTAMP(7)WITH TIME ZONE); DD-MON-YY 12.00.00.000000 -5.00 start_date TIMESTAMP(7) WITH LOCAL TIME ZONE); INTERVAL '312-2' YEAR(3) TO MONTH); INTERVAL '312-2' YEAR(3) INTERVAL '300' MONTH(3)); Converting a character string to a timestamp: SELECT TO_TIMESTAMP ('1999-12-01 11:00:00', 'YYYY-MM-DD HH:MI:SS')
To create a table, a user must have CREATE TABLE privilege and a storage area in which to create objects. This privilege is given via the database administrator using DCL schema -who owns the table (a schema is a collection of objects that directly refer to the data in a database. Schema objects include: tables, views, synonyms, sequences, stored procedures, indexes, clusters and database links table - name of table column -name of each column datatype - the column's datatype and length DEFAULT expr -any default values not incl. in INSERT statement
1.
DESCRIBE locations -- this statement will confirm the creation of the table 2. CREATE TABLE USING THE "AS SUBQUERY" table use another table to create a new
CREATE TABLE foreign_locations AS SELECT location_id, city .... FROM locations WHERE city IN ( 'Roma', 'London', 'Tokyo');
Create Table continued.... CREATE TABLE finance_department AS SELECT employee_id, first_name, last_name, job_id,
salary*12 ANNSAL, hire_date FROM employees WHERE department_id = 50;
ALTER TABLE animal DROP COLUMN owner_lname; **only one column at a time is dropped
** the table must have at least one column remaining in it after it is altered **once a column is dropped, it cannot be recovered **any other columns is the table that are marked SET UNUSED option are dropped, too.
DROPPING A TABLE
Dropping a table removes the definition of an Oracle table. The database loses all the data in the table and all the indexes associated with it. All data is deleted from the table, any views and synonyms remain but are invalid, all pending transactions are committed. Only the creator of the table or a user with DROP ANY TABLE privilege can remove a table. This procedure once executed, is irreversible. As all DDL, it is automatically committed. Oracle Server does NOT question the action! DROP TABLE animal2
TRUNCATE A TABLE
Truncate a table is used to remove all rows from a table and to release the storage space used by that table. Truncate is a faster way to remove rows because it generates NO rollback information, does not fire the delete triggers of the table. If the table is the parent of a referential integrity constraint, you cannot truncate the table. Disable the constraint before issuing the TRUNCATE statement. You can also use the DELETE statement to remove a table but the DELETE does not release storage space.
DELETE
DML generates rollback because DML statements require commit uses WHERE clause can be used with SUBQUERY does not ask for confirmation can use ON DELETE CASCADE if set in column definition
TRUNCATE
DDL generates NO rollback because DDL statements are automatically committed faster does not fire the table delete triggers does not ask for confirmation table definition is left intact (indexes, triggers, and constraints)