Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Cidade de Assomada,
Rua 5 de Julho, CP 4
Pretende-se com este exercícios familiarizar os alunos com a sintaxe de queries para manipulação de
dados, utilizando o oracle.
Criação de Tabelas
Sintaxe:
Onde
• GLOBAL TEMPORARY specifies that the table's rows are temporary and such tables are
known as temporary tables.
• The duration of the contents are specified by the ON COMMIT clause.
• A temporary table is visible to all sessions, but rows are specific to a session.
• Type specifies the type of a column.
• Constraint_def specifies the definition of a constraint on a column.
• default_exp specifies the expression used to assign a default value to a column.
• ON COMMIT controls the duration of the rows in a temporary table.
• DELETE specifies the rows are deleted at the end of a transaction.
• PRESERVE specifies the rows are deleted at the end of a session.
• If you commit ON COMMIT for a temporary table, the default is DELETE.
1
1) Exemplo - Create Table
2) Inserir Dados
SQL>
SQL> -- prepare data
SQL> insert into Employee(ID, First_Name, Last_Name, Start_Date,
End_Date, Salary, City, Description)
2 values ('01','Jason', 'Martin', to_date('19960725','YYYYMMD
D'), to_date('20060725','YYYYMMDD'), 1234.56, 'Toronto', 'Programmer')
3 /
1 row created.
1 row created.
1 row created.
1 row created.
2
1 row created.
1 row created.
2) Pesquisas
Seleccionar todos os empregados:
3) Copiar tabelas
Seleccionar todos os empregados com residência na cidade de Vancouver e com salário maior que
2344,76 USD.
SQL>
SQL> create table emp_copy as
3
select * from employee;
Table created.
SQL>
SQL> select * from emp_copy;
1) ALTERAR Tabelas
SQL>
SQL> ALTER TABLE employee
ADD modified_by INTEGER;
1) Apagar Tabelas
SQL> drop table emp_copy;
Table dropped.