Baixe o app para aproveitar ainda mais
Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original
ALTER TABLE O que podemos fazer com Alter Table ? Como? 1 Renomear uma Tabela Alter Table Cliente Rename to Consumidor 2 Definir uma coluna como chave primária Alter Table Cliente Add Primary Key (IDCliente) Cliente 3 Definir uma coluna (IDCliente da Tabela Pedido) como chave estrangeira (referenciando IDCliente da Tabela Cliente) Alter Table Pedido Add Foreign Key (IDCliente) References Cliente (IDCLiente) IDCliente Integer 4 Renomear uma coluna (Renomear NomeCliente para Consumidor) Alter Table Cliente Rename Column NomeCliente to NomeConsumidor NomeCliente Varchar(60) 5 Definir NomeCLiente como uma coluna de valores Obrigatórios Alter Table Cliente Add Check (NomeCliente Is not null) Sexo Char 6 Definir Sexo como uma coluna que só poderá receber os valores 'M' ou 'F' em Maiúsculas Alter Table Cliente Add Check (Sexo in ('M','F')) 7 Definir a DataHora como um atributo único Alter Table Pedido Add Unique (DataHora) Pedido 8 Remover Coluna Alter Table Pedido DROP COLUMN DataHora IDPedido Integer IDCliente Integer DataHora Date DIVISÕES SQL Divisões da Linguagem SQL SIGLA DESCRIÇÃO COMANDOS DDL Data Definition Language Create Table, Alter table, Drop Table, Create View, Drop View DTL Data Transation Language Commit e RollBack DCL Data Control Language Creat User, Drop User, Grant, Revoke DML Data Manipulation Language Insert, Update, Delete DQL ou DRL - Subclassificação de DML Data Query Language ou Data Retrieve Language. Select Obs: alguns autores classificam o comando seletec como sendo um comando DML CONSULTA Endereco CodEnd TipoLog Log Num Complemento 1 Rua Eliomar Dias 39 Apto 1012 2 Avenida Soares de Castro 3001 Casa 6 3 Praça Xavier Lima 328 Crie uma consulta que exiba os seguiintes Dados no seguinte formato: Endereco Rua Eliomar Dantas, 39 apto 1012 Praça Xavier Lima, 328 Select TipoLog ||' '||log ||','||Num||' '|| Complemento from Endereco where codEnd in (1,3); SUBCONSULTA Exibir todos os dados de imóveis caso exista um nomeTipoImovel com o valor 'loft': Select * from Imovel where Exists (Select * from tipoImovel where NomeTipoImovel = 'loft')
Compartilhar