Professional Documents
Culture Documents
Tema Sectiunea 13
Tema Sectiunea 13
Tema Sectiunea 13
Vocabulary
Data Dictionary->Created and maintained by the Oracle Server and contains
information
about the database
Schema->A collection of objects that are the logical structures that directly
refer to the data in the database
Vocabulary
INTERVAL YEAR TO MONTH->Allows time to be stored as an interval of years and months
TIMESTAMP LOCAL TIME ZONE->When a column is selected in a SQL statement the time is
automatically
converted to the user�s timezone
TIMESTAMP WITH TIME ZONE->Stores a time zone value as a displacement from Universal
Coordinated
Time or UCT
b.
CREATE TABLE time_ex4
(loan_duration1 INTERVAL YEAR(3) TO MONTH,
loan_duration2 INTERVAL YEAR(2) TO MONTH);
INSERT INTO time_ex4 (loan_duration1, loan_duration2 )
VALUES( INTERVAL '120' MONTH(3), INTERVAL '3-6' YEAR TO MONTH);
c.
CREATE TABLE time_ex5
(day_duration1 INTERVAL DAY(3) TO SECOND,
day_duration2 INTERVAL DAY(3) TO SECOND);
INSERT INTO time_ex5 (day_duration1, day_duration2 )
VALUES( INTERVAL '25' DAY(2), INTERVAL '4 10:30:10' DAY TO SECOND);
2.
SELECT * FROM time_ex3;
Try It / Solve It
1.
Greseli pot fi facute, iat schimbarea e permanenta.
2.
a.CREATE TABLE artists
(artist_id NUMBER(5,0),
first_name VARCHAR2(25),
last_name VARCHAR2(25),
band_name VARCHAR2(25),
email VARCHAR2(25),
hr_rate NUMBER(8,2),
song_id NUMBER(5,0)
);
b.
INSERT INTO artists (artist_id, first_name, last_name, band_name, email, hr_rate,
song_id)
c.
INSERT INTO artists (artist_id, first_name, last_name, band_name, email, hr_rate,
song_id)
VALUES(12,'Christina','Aguilera','Lilo Band','lilo.band@gmail.com','456.23',NULL);
d.
1)ALTER TABLE artists
ADD (genra VARCHAR2(100));
2)ALTER TABLE artists
DROP COLUMN genra;
3)RENAME artists TO theNewArtists;
4)TRUNCATE TABLE artists;
5)COMMENT ON TABLE artists
IS "These are the best artists";
3.
ALTER TABLE o_employees
ADD ("Termination" VARCHAR2(100) DEFAULT TO_CHAR(SYSDATE,'Month ddth, YYYY') );
4.
ALTER TABLE o_employees
ADD (start_date TIMESTAMP WITH LOCAL TIME ZONE);
5.TRUNCATE TABLE o_jobs;
coloanele sunt inca acolo, dar a disparut data;
6.
DROP->sterge definitia tabelului din baza de data impreuna cu datele
se poate folosi flashback
TRUNCATE->sterge inregistrarile si elibereaza spatiul de memorie
nu se pot recupera datele
DELETE->sterge randurile dar nu curata spatiul de stocare
7.
crestere precizie pt coloana cu numere/decrestere daca sunt numai null uri
crestere lungime coloana cu stringuri/decrestere pana la cea mai mare lungime
existenta
schimbare tip de data daca sunt null in tabel
specificare/modificare valoare default
o coloana poate fi stearsa(trebuie sa ramana cel putin o coloana in tabel)
setare ca si unused
8.
COMMENT ON TABLE o_jobs IS 'New job description added';