<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6831046906749359917</id><updated>2024-08-28T23:41:44.088-03:00</updated><category term="db2"/><category term="sql"/><category term="z/os"/><title type='text'>DB2 z/OS - O DB2 do Mainframe</title><subtitle type='html'>Novidades, ferramentas, soluções, contatos. Tudo o que for relacionado ao DB2 na plataforma mainframe.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://db2mainframe.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6831046906749359917/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://db2mainframe.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6831046906749359917.post-4459434732561054830</id><published>2009-10-13T09:09:00.000-03:00</published><updated>2009-10-13T09:09:57.693-03:00</updated><title type='text'>Principios básicos do DB2</title><content type='html'>Começado com o último post pretendo colocar aqui alguns outros com os príncipios básicos do DB2. No primeiro post escrivi sobre a relação do DB2 com o z/OS. Os outros posts serão sobre: Arquiterua do DB2, Estrutura de Dados, e Estrutura de Sistema.</content><link rel='replies' type='application/atom+xml' href='http://db2mainframe.blogspot.com/feeds/4459434732561054830/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6831046906749359917/4459434732561054830' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6831046906749359917/posts/default/4459434732561054830'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6831046906749359917/posts/default/4459434732561054830'/><link rel='alternate' type='text/html' href='http://db2mainframe.blogspot.com/2009/10/principios-basicos-do-db2.html' title='Principios básicos do DB2'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6831046906749359917.post-3080970571796452912</id><published>2009-08-03T13:02:00.003-03:00</published><updated>2009-08-03T13:10:19.149-03:00</updated><title type='text'>Arquitetura DB2 para o z/OS</title><content type='html'>Aqui temos um pequeno tópico sobre a arquitetura do DB2 para o Mainframe.&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;A arquitetura do DB2 para z/OS&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;z/OS&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;O z/OS é o sistema operacional para zSeries baseado na arquitetura de 64-bit. Ele é a geração seguinte ao OS/390.&lt;br /&gt;&lt;br /&gt;A integração do DB2 com o z/OS está cada vez maior permitindo um melhor uso das funções do z/OS. A arquitetura do DB2 foi redesenhada para poder aproveitar o suporte ao endereçamento virtual em 64-bit (64-bit virtual address support).&lt;br /&gt;&lt;br /&gt;O DB2 se beneficia dos seguintes componentes da nova arquitetura para zSeries:&lt;br /&gt;• 64-bit Storage: Aumenta de 2GB para 64GB a capacidade central de memória eliminando a maior parte do limite de armazenamento (storage contraints ???). Com o armazenamento de 64-bit existem 16 exabytes de endereçamento de memória (vamos utilizar address space) virtual. Esse tipo de arquitetura ainda aumenta a disponibilidade e escalabilidade e simplifica o gerenciamento de espaço.&lt;br /&gt;• Comunicação em alta velocidade: Hipersockets possibilita comunicação TCP-IP em alta velocidade entre as partições de um mesmo servidor zSeries, por exemplo, entre o Linux para zSeries e o DB2 z/OS.&lt;br /&gt;• Gerenciamento de workload dinâmico: O gerenciador de espaço (storage) para o z/OS, IRD (Intelligent Resource Director), expande a capacidade do WLM (workload manager) gerenciando dinamicamente de acordo com as prioridades de workload.&lt;br /&gt;&lt;br /&gt;Em adição aos benefícios da arquitetura z, o DB2 tem mais outras vantagens das opções do sistema operacional z/OS:&lt;br /&gt;• Maior Segurança: z/Series, z/OS e outros predecessores tem provido uma segurança robusta. As opções de segurança disponibiliza privacidade para usuários, aplicações e dados e protege a integridade e isola os processos que estão rodando. As funções atuais de segurança evoluiriam para incluir uma rede compreensiva e segurança transacional que operam em diversos outros sistemas operacionais. Melhoras no z/OS Security Server e Tivoli aumentam as opções de segurança, bem como multilevel security.&lt;br /&gt;• Tecnologia de software aberto: z/OS usa as mais novas tecnologias para software aberto que incluem Entreprise JavaBeans, XML e UNICODE.&lt;br /&gt;• Tecnologia de cluster: o z/OS Parallel Sysplex disponibiliza uma tecnologia de cluster que possibilita a disponibilidade do sistema 24 horas por dia, 7 dias por semana. Tecnologia de cluster também possibilita a capacidade de crescimento horizontal. Crescimento horizontal resolve os problemas de overhead de performance e problemas de gerenciamento de sistemas encontrados em sistemas com diversas máquinas que acessam o mesmo banco de dados. Com crescimento horizontal, maior escalabilidade é alcançada; o sistema pode crescer além do limite de uma  única máquina enquanto seu banco de dados permanece intacto.&lt;br /&gt;• Processadores mais rápidos: Com processadores mais rápidos e poderosos, o DB2 alcança maiores graus de paralelismos de queries e níveis mais altos de movimentos transacionais.&lt;br /&gt;• Melhora da tecnologia de I/O: O IBM Entreprise Storage (ESS) explora o acesso paralelo de volumes e Multiple Allegiance(?) (opções do z/OS) e suporta até 256 me/Os por volume de disco lógico. Um único ambiente z/OS pode ter I/Os em paralelo no mesmo volume lógico e diferentes ambientes podem ter I/Os em um volume compartilhado em paralelo.&lt;br /&gt;• Canais FICON: Esses canais oferecem significantes benefícios de performance para transações de workload. As características FICON, por exemplo uma rápida taxa de transferência de dados (100MB por segundo), resulta também varredura de tabela mais rápida e melhora a performance de utilitários.&lt;br /&gt;• Melhora da compressão de hardware: A melhora na compressão de hardware teve um impacto positivo da performance. Por exemplo, utilitários que rodam em dados compressados rodam mais rápidos.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;O DB2 em um ambiente z/OS&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;O DB2 opera como um subsistema formal do z/OS.&lt;br /&gt;&lt;br /&gt;Os processos do z/OS são separados em regiões que são chamados address spaces. Os processos do DB2 z/OS são executados em diversos address spaces diferentes. Alguns processos de aplicações do DB2 rodam em um address space que solicitam serviços ao DB2 como WebSphere, IMS, e CICS.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Subsystem&lt;/span&gt;&lt;br /&gt;O Subsistema é um sistema secundário ou subordinado que é usualmente capaz de operar independentemente de, ou não sincronizado com, um controlador de sistema. O subsistema DB2 é uma instancia distinta de um DBMS relacional. O software controla tanto a criação, organização e alteração de um banco de dados e o acesso aos dados que o banco de dados armazena.&lt;br /&gt;&lt;br /&gt;O DB2 trabalha eficientemente com outros subsistemas do z/OS e componentes. Nesse mesmo capítulo serão explicados alguns componentes chaves – o z/OS Security Server e o zSeries Parallel Sysplex.&lt;br /&gt;&lt;br /&gt;Os utilitários do DB2 rodam no ambiente batch do z/OS. Aplicações que acessam recursos do DB2 podem rodar em um mesmo sistema z/OS no CICS, IMS, TSO ou em ambiente batch ou em outro sistema operacional. Essas aplicações podem acessar recursos do DB2 usando serviços cliente/servidor do DB2 distribued data facility (DDF). A IBM disponibiliza ‘attachment facilities’ para conectar o DB2 em cada um desses ambientes.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;DB2 lock manager&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;O IRLM do DB2 (internal resource lock manager) é tanto um subsistema separado com um componente integral do DB2. Cada subsistema DB2 deve ter seu próprio IRLM.&lt;br /&gt;&lt;br /&gt;O IRLM trabalha com o DB2 para controlar o acesso aos dados. O DB2 pede o lock do IRLM para garantir a integridade dos dados quando aplicações, utilitários e comandos que tentam acessar os mesmos dados.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;DB2 e o z/OS Security Server&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Para controlar o acesso para o seu sistema z/OS, pode ser usado o RACF (resource access control facility) que é um componente do z/OS Security Server ou um produto equivalente. Quando usuários começam alguma sessão. O z/OS Security Server checa suas identidades para prevenir acessos não autorizados ao sistema. O z/OS Security Server pode também ser usado para proteger recursos do DB2, como as tabelas.</content><link rel='replies' type='application/atom+xml' href='http://db2mainframe.blogspot.com/feeds/3080970571796452912/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6831046906749359917/3080970571796452912' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6831046906749359917/posts/default/3080970571796452912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6831046906749359917/posts/default/3080970571796452912'/><link rel='alternate' type='text/html' href='http://db2mainframe.blogspot.com/2009/08/arquitetura-db2-para-o-zos.html' title='Arquitetura DB2 para o z/OS'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6831046906749359917.post-8405262823452865634</id><published>2007-12-31T11:46:00.000-03:00</published><updated>2007-12-31T12:09:43.094-03:00</updated><title type='text'>Integridade de Dados</title><content type='html'>&lt;span style=&quot;font-weight: bold;font-size:130%;&quot; &gt;Introdução&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;Nessa era da informação sob demanda não podemos nos contentar em que os dados são apenas registros armazenados em um banco de dados. Sem a devida garantia de sua integridade não podemos transformá-los em informação. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;De nada adianta termos imensos bancos de dados armazenando incontáveis bytes de dados, que são constantemente inseridos, modificados, eliminados, se não podemos transformá-los em informação. E, de preferência, informação útil. E sem garantir que nossos dados armazenados estão íntegros, dificilmente conseguimos transformar esses bytes em informação real. Não importa quão avançada sejam suas ferramentas ou técnicas de aplicação em seu ambiente, nada irá adiantar se não houver um investimento na qualidade de seus dados.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Ao falarmos de integridade de dados, podemos citar alguns exemplos que podem e ajudam a garanti-la:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Firewalls&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Sistema Gerenciador de Banco de Dados (SGDB)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Revisão regular de privilegio aos dados&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Encriptação&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Controle na prevenção de corrupção de dados&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Compliance&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Fácil recuperação de dados e performance&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Integração com os sistemas de armazenamento (discos, fitas)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Trafego dos dados pela rede&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;E mais...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Usando os exemplos citados acima, podemos dividir a integridade dos dados em 2 grupos:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Sob a ótica do sistema: Integração com o hardware como discos, fitas; conexão de rede; firewalls; integração entre o SGDB e o sistema.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Sob a ótica da aplicação: Integridade referencial; triggers; lockings; controle de acesso aos dados.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Nesse artigo será abordado a ótica da aplicação, mais precisamente da parte que depende do Sistema Gerenciador de Banco de Dados (SGDB) de integridade referencial, integridade semântica, integridade de domínio. Cada um desses itens será explicado no decorrer do texto.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;h1&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;O Sistema Gerenciador de Banco de Dados e a integridade dos dados&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Os SQL statements INSERT, DELETE e UPDATE modificam os dados em um banco de dados existentes. Toda vez que os dados são alterados existe a possibilidade que integridade lógica ser afetada. Por exemplo, a inserção de um produto inexistente em um pedido um cliente, ou um cliente pode ser eliminado mesmo tenho ainda pedidos pendentes em seu nome. Em ambos os casos houve perda da integridade dos dados.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;A integridade de dados em SGDBs é uma combinação de:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Integridade semântica: o dado de uma coluna sempre será do tipo de dado definido na criação da coluna&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Integridade de entidade: cada linha de uma tabela possui um indicador que garanta a unicidade da mesma.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Integridade referencial: os relacionamentos lógicos entre as entidades serão forçados pelos SGDB&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Integridade de domínio: Domínio é um conjunto de valores previamente definido no qual uma coluna só poderá conter valores pertencentes a esse domínio.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Quando bem definido um banco de dados, provavelmente esse quatro conceitos de integridade serão aplicados.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;h1&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;Integridade Semântica&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;A integridade semântica garante que o dado inserido em uma linha da tabela seja um valor válido. Esse valor para ser válido deve ser do mesmo tipo de dados definido na especificação da coluna na tabela. Por exemplo, um atributo de uma determinada entidade definido como &lt;/span&gt;&lt;st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;DATA&lt;/span&gt;&lt;/st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt; só conterá dados relativos a &lt;/span&gt;&lt;st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;DATA&lt;/span&gt;&lt;/st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;. É a certeza que no campo &lt;/span&gt;&lt;st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;DATA&lt;/span&gt;&lt;/st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;_CONTRATACAO só conterá datas válidas. Caso um SGDB permita a inserção de um outro tipo de dado diferente do definido, a integridade semântica estará sendo violada.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;A integridade semântica em um SGDB é aplicada com a utilização de constraints. Usarei o termo em inglês nesse caso por dois motivos: 1) não encontrei termo apropriado para a tradução de constraint; 2) sendo os SGDBs na sua maioria escritos em inglês, esse é o termo mais conhecido por todos. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Constraints&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;Constraint pode ser definido resumidamente como uma regra que limita o valor que pode ser inserido, modificado, ou eliminado em uma tabela. Na linguagem SQL temos os seguintes tipos de constraints:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Constraint de dados&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;Constraint NOT NULL (não nulo)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;Constraint única&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Constraint de validação (check constraint)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;br /&gt;Segue abaixo um resumo sobre esses tipos de constraints.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Constraint de dados&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Esse tipo de constraint pode ser considerado o mais simples e por muitas vezes ignorado como um constraint. Ele é o que delimita o tipo de dado de cada coluna em uma tabela. Os tipos de dados disponíveis na maioria dos SGDBs existentes pode ser dividia em:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Numérico&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Alfa numérico ou caracteres&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Data e tempo&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Grandes objetos&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Tipos de dados numéricos mais comuns:&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;  &lt;/p&gt;&lt;table class=&quot;MsoTableGrid1&quot; style=&quot;border: medium none ; border-collapse: collapse;&quot; border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;  &lt;tbody&gt;&lt;tr style=&quot;&quot;&gt;   &lt;td style=&quot;border: 1pt solid black; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;b style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;Tipo   de Dados&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style=&quot;border-style: solid solid solid none; border-color: black black black -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;b style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;Descrição&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;&quot;&gt;   &lt;td style=&quot;border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;SMALLINT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style=&quot;border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;Números   inteiros pequenos&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;&quot;&gt;   &lt;td style=&quot;border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;INTEGER&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style=&quot;border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;Números   inteiros&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;&quot;&gt;   &lt;td style=&quot;border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;DECIMAL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style=&quot;border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;Números   decimais. Contem a parte inteira e a decimal (13,2 por exemplo)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;&quot;&gt;   &lt;td style=&quot;border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;st1:stockticker&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;REAL&lt;/span&gt;&lt;/st1:stockticker&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style=&quot;border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;O   número floating-point de precisão simples é um floating-point de 32 bit&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;&quot;&gt;   &lt;td style=&quot;border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;FLOAT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style=&quot;border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm; page-break-after: avoid;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;O número floating-point de precisão dupla é um   floating-point de 64 bit&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Tipos de dados alfa-numérico ou caracteres:&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;  &lt;/p&gt;&lt;table class=&quot;MsoTableGrid1&quot; style=&quot;border: medium none ; border-collapse: collapse;&quot; border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;  &lt;tbody&gt;&lt;tr style=&quot;&quot;&gt;   &lt;td style=&quot;border: 1pt solid black; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;b style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;Tipo   de Dados&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style=&quot;border-style: solid solid solid none; border-color: black black black -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;b style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;Descrição&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;&quot;&gt;   &lt;td style=&quot;border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;st1:stockticker&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;CHAR&lt;/span&gt;&lt;/st1:stockticker&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style=&quot;border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;Para   cadeias fixas de caracteres alfa numéricos&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;&quot;&gt;   &lt;td style=&quot;border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;VARCHAR&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style=&quot;border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;Para   cadeias variáveis de caracteres alfa numéricos&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Tipos de dados data e tempo:&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;  &lt;/p&gt;&lt;table class=&quot;MsoTableGrid1&quot; style=&quot;border: medium none ; border-collapse: collapse;&quot; border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;  &lt;tbody&gt;&lt;tr style=&quot;&quot;&gt;   &lt;td style=&quot;border: 1pt solid black; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;b style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;Tipo   de Dados&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style=&quot;border-style: solid solid solid none; border-color: black black black -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;b style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;Descrição&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;&quot;&gt;   &lt;td style=&quot;border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;DATE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style=&quot;border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;Data   com valores representando dia, mês e ano&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;&quot;&gt;   &lt;td style=&quot;border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;TIME&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style=&quot;border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;Tempo   com valores representando hora, minuto e segundo&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;&quot;&gt;   &lt;td style=&quot;border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;TIMESTAMP&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style=&quot;border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 221.4pt;&quot; valign=&quot;top&quot; width=&quot;326&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot; lang=&quot;PT-BR&quot;&gt;Data   e Tempo juntos com valores que representam ano, mês, dia, hora, minuto,   segundo e milisegundo&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;br /&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Observação: na perspectiva do usuário, os tipos de dados data e tempo parecem ser do tipo alfa-numérico, porém fisicamente são armazenados como do tipo binário compactado.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Tipos de dados grandes objetos, tais como LOB (large object), armazenam grande quantidade de bytes podem ser utilizados para armazenar objetos do tipo imagem ou som.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Constraint NOT NULL (não nulo)&lt;/span&gt;&lt;/p&gt;      &lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;O conceito de nulo é utilizado quando uma determinada coluna ou atributo de uma linha na tabela não possui valor ou o valor é desconhecido. Pelo outro lado existem colunas / atributo que obrigatoriamente precisam de valor informado. Por exemplo, em uma tabela chamada FUNCIONARIO que dados de funcionários a atributo NUMERO_FUNCIONARIO é obrigatório. Nesse caso é possível utilizar a constraint NOT NULL para garantir que haverá informação nessa coluna.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;Importante frisar aqui que NULO é diferente de brancos e zeros. Temos que lembrar que tanto branco quanto zero são valores validos e que são levados em conta em funções de coluna tais como média, somatório, máximo, mínimo. Sendo que o NULO é desconsiderado nessas funções.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Constraint única&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;          &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;No SQL a constraint única é uma regra que garante que não haverá valores duplicados da mesma coluna ou em um conjunto de colunas na mesma tabela. Usando o mesmo exemplo da tabela FUNCIONARIO, podemos utilizar uma constraint única na coluna NUMERO_FUNCIONARIO para garantir que dois ou mais funcionários possuam o mesmo número de identificação.&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;br /&gt;Podemos considerar que a chave primaria (primary key), que será explicada mais adiante, é um tipo de constraint única. Lembrando que uma tabela pode ter apenas uma chave primária, porém diversas constraint únicas.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;h3&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Constraint de validação (check constraint)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;A constraint de validação determina um conjunto de valores permitidos para uma determinada coluna na tabela. Essas constraints são definidas explicitamente no DDL (data definition language) de uma tabela com expressões Booleanas similares a clausula WHERE do SQL. Constraint de validação é forçada em qualquer inserção ou atualização da coluna. Caso a inserção ou atualização da coluna não esteja de acordo com a definição da constraint, a mesma não será executada.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Por exemplo, vamos supor que a tabela FUNCIONARIO possua uma coluna SALARIO e que o valor do salário de cada funcionário não possa ser maior que 50.000,00, é possível criar uma constraint para essa regra:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;div  style=&quot;border-style: solid none; padding: 1pt 0cm;font-family:courier new;&quot;&gt;  &lt;p class=&quot;SampleCode&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;CREATE TABLE FUNCIONARIO (&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;SampleCode&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;&quot;&gt;      &lt;/span&gt;NUMERO_FUNCIONARIO SMALLINT NOT NULL,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;SampleCode&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;&quot;&gt;      &lt;/span&gt;&lt;/span&gt;SALARIO DECIMAL (9,2) NOT NULL CHECK SALARIO &gt;= 50.000);&lt;/span&gt;&lt;/p&gt;  &lt;/div&gt;&lt;br /&gt; &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Constraint de validação pode ser muito útil para garantir regras de negócio, pois ela não pode ser sobreposta. Uma vez definida é dada a garantia que a regra será respeitada.&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;br /&gt;Utilizando esse tipo de integridade torna as suas aplicações mais robustas, consistentes e simples, pois não é necessário controlar as regras dentro do próprio código de programação ou utilizando uma subrotina. Dessa maneira é isolada em apenas um lugar a regra de negócio. Havendo a necessidade de mudar alguma regra de negócio, basta apenas mudar a constraint de validação na tabela ao invés de sair alterando códigos e mais códigos de programação uma vez que a mesma regra pode estar replicada em diversos pontos da sua aplicação.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;h1&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;Integridade Referencial&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;      &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Em resumo, integridade referencial é um conceito de banco de dados que garante que todos os relacionamentos propostos entre tabelas no modelo de entidade-relacionamento (ER) serão respeitados dando a certeza que os dados de um banco de dados estarão íntegros. Esses relacionamentos são baseados nas definições de uma chave primária e uma chave estrangeira e regras pré-definidas para a manipulação dessas chaves.&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;br /&gt;Vale lembrar que existem diversos livros, manuais, tratados que falam sobre integridade referencial, sendo assim esse artigo apenas deseja explicar de uma maneira simples e com exemplos esse conceitos.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;h2&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;Conceitos de IR (Integridade Referencial)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;    &lt;span style=&quot;;font-family:Arial;font-size:100%;&quot;  lang=&quot;PT-BR&quot; &gt;A figura abaixo mostra alguns conceitos de IR e o uso de sua terminologia:&lt;/span&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibhNyclT6rXYDjvWYoFeyGbDzpJcZXSDl0BdWLJ1EsFe3myhvnt6EcbSeYVBNzFSqMQ_woD-Ppzaps4IjK86G9GgkiIqdhf3YHQgD9Mg-FDfpre7Cl6DtIl0HxJKDjblrIAeWPDKJ1BKJr/s1600-h/RI+Conceito.gif&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibhNyclT6rXYDjvWYoFeyGbDzpJcZXSDl0BdWLJ1EsFe3myhvnt6EcbSeYVBNzFSqMQ_woD-Ppzaps4IjK86G9GgkiIqdhf3YHQgD9Mg-FDfpre7Cl6DtIl0HxJKDjblrIAeWPDKJ1BKJr/s320/RI+Conceito.gif&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5150150147951192834&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;h1&gt;  &lt;/h1&gt;&lt;h3&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Chave Candidata&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;        &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;Chave candidata é um atributo ou um conjunto de atributos de uma tabela que identifica uma única linha da tabela. A chave primária é extraída a partir do conjunto de chaves candidatas de uma tabela.&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;br /&gt;Na Figura 1 as chaves candidatas da tabela FUNCIONARIO o NR_&lt;/span&gt;&lt;st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;FUNC&lt;/span&gt;&lt;/st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt; (número do funcionário) e NR_&lt;/span&gt;&lt;st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;CPF&lt;/span&gt;&lt;/st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt; (número do &lt;/span&gt;&lt;st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;CPF&lt;/span&gt;&lt;/st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;) por que eles garantem a unicidade de uma linha na tabela. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;h3&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Chave Única&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Uma chave única que definida pela constraint única que garante que um atributo ou um conjunto de atributos não pode ser duplicado na mesma tabela.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Chave Primária&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;A chave primária de uma tabela é uma das chaves candidatas que melhor identifica uma tabela. Os critérios para escolher a chave primária são:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;O conteúdo da coluna ou do conjunto de colunas deve sempre existir, em outras palavras deve possuir a constraint semântica NOT NULL.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;O valor da chave não deve poder ser alterado.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;A chave primária tem as seguintes características:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Apenas uma chave primária por tabela&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Pode ser composta por mais de uma coluna&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Obrigatoriamente ser NOT NULL (não nulo)&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;No exemplo mostrado na Figura 1 a coluna NR_&lt;/span&gt;&lt;st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;FUNC&lt;/span&gt;&lt;/st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt; da tabela foi escolhida como chave primária uma vez o NR_&lt;/span&gt;&lt;st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;CPF&lt;/span&gt;&lt;/st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;, apesar de não usual, pode conter valor nulo já que no momento da contratação o funcionário pode não ter o &lt;/span&gt;&lt;st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;CPF&lt;/span&gt;&lt;/st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Na mesma figura, a chave primaria da tabela DEPARTAMENTO é NR_DEPT (número do departamento).&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Chave Estrangeira&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;A chave estrangeira se refere ou é relacionada com alguma chave primaria de uma tabela, podendo ser inclusive da mesma tabela. É a concretização do relacionamento proposto no modelo entidade-relacionamento (&lt;/span&gt;&lt;st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;MER&lt;/span&gt;&lt;/st1:stockticker&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;A chave estrangeira tem as seguintes características:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Uma tabela pode possuir zera, uma ou diversas chaves primárias&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Pode ser composta de uma ou mais colunas contando que ela seja exatamente igual à chave primaria que ela é relacionada (tipo de dado e tamanho)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Pode conter a clausula NULL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;Na figura 1, a coluna NR_DEPT da tabela FUNCIONARIO é uma chave estrangeira que referencia a tabela DEPARTAMENTO cuja chave primária é NR_DEPT.&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Chave Parente&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;A chave parente é uma chave única que é referenciada pela chave estrangeira. Pode ser tanto a chave primaria como uma outra chave única existente na tabela. Os valores da chave parente determinam os valores validos da respectiva chave estrangeira.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Tabela parente&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;Uma tabela parente é uma tabela que possui chaves parentes que é referenciada por uma ou mais chaves estrangeiras.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;A tabela DEPARTAMENTO da Figura 1 é uma tabela parente pois possui uma chave primária, NR_DEPT, que é referenciado por uma chave estrangeira na tabela FUNCIONARIO.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;Normalmente as chaves estrangeiras são referenciadas por chaves primárias, mas nada impede que seja referenciada por uma chave única.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;font-weight: bold;font-size:130%;&quot; &gt;Tabela Dependente&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;Toda tabela que possui uma ou mais chaves estrangeiras é uma tabela dependente. Uma tabela dependente pode não possuir uma chave primária mas mesmo assim também pode ser uma tabela parente.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;A tabela FUNCIONARIO é uma tabela dependente da tabela DEPARTAMENTO por possuir uma chave estrangeira que referencia essa tabela.&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Tabela Independente&lt;/span&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;      &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Uma tabela que não possui chave estrangeira é chamada de tabela independente.&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Linha Dependente&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;      &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;Uma linha dependente é uma linha de uma tabela dependente no qual o valor da chave estrangeira não é nulo.&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Integridade de entidade&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;      &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;A obrigatoriedade que uma chave primária não possa conter valores NULOS e que ela é única na tabela define a regra integridade de entidade.&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Constraint Referencial&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;É a constraint que define a Integridade Referencial (IR) de relacionamentos entre tabelas em um banco de dados. O conceito de IR garante que todos os valores não nulos existentes em uma chave estrangeira são iguais aos da chave primária que ela referencia.&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;  &lt;/p&gt;&lt;h1&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;Regras e opções de IR&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;O modelo relacional possui um conjunto de regras para controle da inserção, atualização e eliminação dos dados nas tabelas. As regras são:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Regra de Inserção (INSERT)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Regra de Atualização (UPDATE)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Regra de Eliminação (DELETE)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Regra de Inserção&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;A regra de inserção é uma regra implícita, diferentemente das regras de atualização e eliminação que precisam ser declaradas no momento de criação das chaves estrangeiras. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;Essa regra define que qualquer linha inserida na tabela dependente deve conter o valor na chave estrangeira no qual será:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Nulo, se for permitido nulo na chave estrangeira&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Exatamente o mesmo valor da chave parente da respectiva tabela parente.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;Independente se a tabela dependente possui uma ou mais chave parente, a regra de inserção garante que o valor inserido estará integro em relação aos seus relacionamentos.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Regra de Atualização&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;A regra de atualização deve ser explicitamente definida no momento de criação da chave estrangeira. Essa regra é acionada quando:&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;A chave estrangeira da tabela dependente é atualizada.&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;Nesse caso, assim como a regra de inserção, o valor só pode ser alterado para nulo, caso seja permitido, ou para um valor existente na chave parente da tabela parente.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;A chave primária da tabela parente é atualizada&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Existem três opções para a regra de atualização:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;RESTRITO:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot; style=&quot;margin-left: 72pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;&quot;&gt;o&lt;span style=&quot;&quot;&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;A chave parente não pode ser atualizada caso exista alguma chave estrangeira em qualquer tabela dependente que o possua o mesmo valor.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;CASCATA:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot; style=&quot;margin-left: 72pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;&quot;&gt;o&lt;span style=&quot;&quot;&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Caso a chave parente seja atualizada, todas as chaves estrangeiras respectivas de cada tabela dependente que contenha o valor da chave parente serão também atualizadas para o novo valor.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;NULO:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;ListTahoma1&quot; style=&quot;margin-left: 72pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;&quot;&gt;o&lt;span style=&quot;&quot;&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Caso a chave parente seja atualizada, todas as chaves estrangeiras respectivas de cada tabela dependente que contenha o valor da chave parente serão atualizadas com o NULO.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Cada chave estrangeira é associada a sua regra de atualização respectiva. A regra de atualização determina se a atualização pode ser feita ou não. Sendo assim, uma chave parente não poderá ser atualizada caso qualquer chave estrangeira respectiva for definida com a regra RESTRITO.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Regra de Eliminação (delete)&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Do mesmo modo que a regra de atualização, a regra de eliminação deve ser definida no momento da criação da chave estrangeira. Essa regra é imposta toda vez que houver tentativa de eliminar uma linha da tabela parente.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;Essa regra também possui as mesmas três opções da regra de atualização:&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;RESTRITO:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot; style=&quot;margin-left: 72pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;&quot;&gt;o&lt;span style=&quot;&quot;&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;A linha da tabela parente não pode ser eliminada caso exista na tabela dependente o mesmo valor na chave parente e de sua respectiva chave estrangeira. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;CASCATA:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot; style=&quot;margin-left: 72pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;&quot;&gt;o&lt;span style=&quot;&quot;&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Todas as linhas de qualquer tabela dependente que possua o valor na chave estrangeira igual ao valor da chave parente também serão eliminadas.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot; style=&quot;margin-left: 72pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;&quot;&gt;o&lt;span style=&quot;&quot;&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;A eliminação é propagada para os dependentes das tabelas dependentes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot; style=&quot;margin-left: 72pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;&quot;&gt;o&lt;span style=&quot;&quot;&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Se uma das eliminações falharem o processo inteiro falha também&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;NULO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;ListTahoma1&quot; style=&quot;margin-left: 72pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;&quot;&gt;o&lt;span style=&quot;&quot;&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Todas as linhas de qualquer tabela dependente que possua o valor na chave estrangeira igual ao valor da chave parente serão atualizadas para o valor NULO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;Cada chave estrangeira possui sua própria regra de eliminação. A regra de eliminação determina se uma linha pode ser ou não eliminada. Portanto uma linha pode não ser eliminada caso:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;ListTahoma1&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Uma ou mais chave estrangeira possua a regra RESTRITO, ou&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span  lang=&quot;PT-BR&quot; style=&quot;font-family:Symbol;&quot;&gt;&lt;span style=&quot;&quot;&gt;·&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Quando possua a regra CASCATA e no momento da propagação da eliminação encontre alguma chave estrangeira que esteja definida como RESTRITO nas tabelas dependentes da tabela dependente.&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;A figura 2 mostra exemplo de um modelo de entidade-relacionamento com suas respectivas regras de eliminação:&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNGptBDKH54yIsYhUX_mvvTo7xVSFKj9VwshdYMM857gPKRYZUmPM0SWi9bru3oUXWLbiJL9tuLY9xH0vsJhG-fqzPcDFet3pHF5ZJEfpIZrSSHCCD0v-L9zcW_pfJzJgFYHq6VHp4IPsV/s1600-h/IR+Regra+dele%C3%A7%C3%A3o.gif&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNGptBDKH54yIsYhUX_mvvTo7xVSFKj9VwshdYMM857gPKRYZUmPM0SWi9bru3oUXWLbiJL9tuLY9xH0vsJhG-fqzPcDFet3pHF5ZJEfpIZrSSHCCD0v-L9zcW_pfJzJgFYHq6VHp4IPsV/s320/IR+Regra+dele%C3%A7%C3%A3o.gif&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5150152656212093714&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt; &lt;h1&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;Conclusão&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;      &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;No mundo atual, aonde a informação vem se tornando cada vez valiosa, de nada adianta termos imensos bancos de dados contendo milhares de dados sem garantimos a integridade desses dados. A Integridade Referencial é um conceito que existe desde os primórdios do banco de dados e hoje entra como um papel fundamental para a garantia da veracidade das informações armazenadas.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: times new roman;font-size:78%;&quot; &gt;&lt;span style=&quot;font-size: 12pt;&quot; lang=&quot;PT-BR&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: arial;font-size:100%;&quot; &gt;&lt;span style=&quot;font-size: 12pt;&quot; lang=&quot;PT-BR&quot;&gt;Praticamente todos os Sistemas Gerenciadores de Banco de Dados (SGDB) possuem mecanismos para a implementação da IR facilitando o trabalho de programadores e analistas, pois, uma vez implementada existe a garantia que o SGDB irá gerenciá-la com todas essas regras em um único lugar encapsuladas.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://db2mainframe.blogspot.com/feeds/8405262823452865634/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6831046906749359917/8405262823452865634' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6831046906749359917/posts/default/8405262823452865634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6831046906749359917/posts/default/8405262823452865634'/><link rel='alternate' type='text/html' href='http://db2mainframe.blogspot.com/2007/12/integridade-de-dados.html' title='Integridade de Dados'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibhNyclT6rXYDjvWYoFeyGbDzpJcZXSDl0BdWLJ1EsFe3myhvnt6EcbSeYVBNzFSqMQ_woD-Ppzaps4IjK86G9GgkiIqdhf3YHQgD9Mg-FDfpre7Cl6DtIl0HxJKDjblrIAeWPDKJ1BKJr/s72-c/RI+Conceito.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6831046906749359917.post-7986961328252833285</id><published>2007-12-20T16:00:00.000-03:00</published><updated>2007-12-20T20:48:31.345-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="db2"/><category scheme="http://www.blogger.com/atom/ns#" term="sql"/><category scheme="http://www.blogger.com/atom/ns#" term="z/os"/><title type='text'>Melhorias no SQL do DB2 V8 z/OS</title><content type='html'>E para começar, o primeiro assunto postado aqui é sobre algumas melhorias no SQL do DB2 z/OS V8.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;&lt;span lang=&quot;PT-BR&quot;&gt;&lt;span style=&quot;COLOR: rgb(0,0,0);font-size:100%;&quot; &gt;Melhorias no SQL do DB2 V8 z/OS&lt;/span&gt;&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;A versão 8 do DB2 trouxe novos statements SQL para facilitar e melhorar a vida de todos que usam o DB2. Aqui segue uma lista de todas as novas funcionalidades do SQL.&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;SELECT from INSERT&lt;span style=&quot;font-size:0;&quot;&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Objeto Sequence&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Melhorias para colunas do tipo Identity&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Predicado DISTINCT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Scalar fullselect&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;Multiple-row INSERT e FETCH&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Expressões de tabelas&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;?xml:namespace prefix = st1 /&gt;&lt;st1:stockticker&gt;&lt;span lang=&quot;PT-BR&quot;&gt;GET&lt;/span&gt;&lt;/st1:stockticker&gt;&lt;span lang=&quot;PT-BR&quot;&gt; DIAGNOSTICS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Dynamic scrollable cursors&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Melhorias na linguagem SQL procedural&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Uso mais freqüente de indicies&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;SQL statements maiores e mais complexos&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Multiple DISTINCT keywords&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Expressões na cláusula GROUP BY&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Menos restrições para funções de colunas&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Nomes das colunas qualificados no statement de INSERT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Clausula ORDER BY para o statement SELECT INTO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Formatos de input adicionais para timestamp&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Colunas ROWID explicitamente definidas não são mais necessárias para LOBs&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Comentários para planos e packages&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Drop implícito para tabelas temporárias globais no commit&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Mudanças no SQL para multilevel security com granularidade de coluna&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Comentários nos statements SQL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Encriptação e desencriptação de dados&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Melhor controle sobre os locks em queires&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;Vamos começar esse post com a explicação do SELECT from INSERT statement. Os demais itens listados serão contemplados também com o passar dos dias&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;SELECT from INSERT&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;Esse novo statement SQL permite a seleção de colunas de uma tabela no momento da inserção dos dados. Imagine uma tabela que tenha definição de uma coluna do tipo IDENTITY como o exemplo abaixo:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;BORDER-RIGHT: medium none; PADDING-RIGHT: 0cm; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0cm; PADDING-BOTTOM: 1pt; BORDER-LEFT: medium none; PADDING-TOP: 1pt; BORDER-BOTTOM: 1pt solid&quot;&gt;&lt;samp&gt;CREATE&lt;/samp&gt; &lt;samp&gt;TABLE&lt;/samp&gt; &lt;samp&gt;EMPLOYEE&lt;/samp&gt; &lt;p class=&quot;SampleCode&quot;&gt;&lt;samp&gt;&lt;/samp&gt;&lt;samp&gt;(EMPNO&lt;/samp&gt; &lt;samp&gt;INTEGER&lt;/samp&gt; &lt;samp&gt;GENERATED&lt;/samp&gt; &lt;samp&gt;ALWAYS&lt;/samp&gt; &lt;samp&gt;AS&lt;/samp&gt; &lt;samp&gt;IDENTITY,&lt;/samp&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class=&quot;SampleCode&quot;&gt;&lt;samp&gt;NAME&lt;/samp&gt; &lt;st1:stockticker&gt;&lt;samp&gt;CHAR&lt;/samp&gt;&lt;/st1:stockticker&gt;&lt;samp&gt;(30),&lt;/samp&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class=&quot;SampleCode&quot;&gt;&lt;samp&gt;SALARY&lt;/samp&gt; &lt;samp&gt;DECIMAL(10,2),&lt;/samp&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class=&quot;SampleCode&quot;&gt;&lt;samp&gt;DEPTNO&lt;/samp&gt; &lt;samp&gt;SMALLINT,&lt;/samp&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class=&quot;SampleCode&quot;&gt;&lt;samp&gt;LEVEL&lt;/samp&gt; &lt;st1:stockticker&gt;&lt;samp&gt;CHAR&lt;/samp&gt;&lt;/st1:stockticker&gt;&lt;samp&gt;(30),&lt;/samp&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class=&quot;SampleCode&quot;&gt;&lt;samp&gt;HIRETYPE&lt;/samp&gt; &lt;samp&gt;VARCHAR(30)&lt;/samp&gt; &lt;samp&gt;NOT&lt;/samp&gt; &lt;samp&gt;NULL&lt;/samp&gt; &lt;samp&gt;WITH&lt;/samp&gt; &lt;samp&gt;DEFAULT&lt;/samp&gt; &lt;samp&gt;&#39;New&lt;/samp&gt; &lt;samp&gt;Hire&#39;,&lt;/samp&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class=&quot;SampleCode&quot;&gt;&lt;samp&gt;HIREDATE&lt;/samp&gt; &lt;samp&gt;DATE&lt;/samp&gt; &lt;samp&gt;NOT&lt;/samp&gt; &lt;samp&gt;NULL&lt;/samp&gt; &lt;samp&gt;WITH&lt;/samp&gt; &lt;samp&gt;DEFAULT);&lt;/samp&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;span lang=&quot;PT-BR&quot;&gt;A coluna EMPNO é definida como IDENTITY. Nesse caso, quando há inserção de dados nessa tabela, a coluna EMPNO não é referenciada, pois o próprio DB2 irá gerar o valor para lá. Antes do DB2 V8 só era possível saber o valor da coluna EMPNO fazendo um SELECT após o INSERT.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;Com o novo statement “SELECT from INSERT” é possível já saber o valor que vai ser atribuído a coluna no momento do INSERT. Portanto no DB2 V8 ao invés de fazer um SELECT &lt;b&gt;após&lt;/b&gt; o INSERT, é possível fazer o SELECT &lt;b&gt;no momento&lt;/b&gt; do INSERT como mostra o exemplo abaixo.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;BORDER-RIGHT: medium none; PADDING-RIGHT: 0cm; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0cm; PADDING-BOTTOM: 1pt; BORDER-LEFT: medium none; PADDING-TOP: 1pt; BORDER-BOTTOM: 1pt solid&quot;&gt;&lt;p class=&quot;SampleCode&quot;&gt;&lt;samp&gt;SELECT&lt;/samp&gt; &lt;samp&gt;EMPNO,&lt;/samp&gt; &lt;samp&gt;HIRETYPE,&lt;/samp&gt; &lt;samp&gt;HIREDATE&lt;/samp&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class=&quot;SampleCode&quot;&gt;&lt;span style=&quot;font-size:0;&quot;&gt;&lt;/span&gt;&lt;samp&gt;FROM&lt;/samp&gt; &lt;samp&gt;FINAL&lt;/samp&gt; &lt;samp&gt;TABLE&lt;/samp&gt; &lt;samp&gt;(INSERT&lt;/samp&gt; &lt;samp&gt;INTO&lt;/samp&gt; &lt;samp&gt;EMPLOYEE&lt;/samp&gt; &lt;samp&gt;(NAME,&lt;/samp&gt; &lt;samp&gt;SALARY,&lt;/samp&gt; &lt;samp&gt;DEPTNO,&lt;/samp&gt; &lt;samp&gt;LEVEL)&lt;/samp&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class=&quot;SampleCode&quot;&gt;&lt;span style=&quot;font-size:0;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:0;&quot;&gt;&lt;/span&gt;&lt;samp&gt;VALUES(&#39;Mary&lt;/samp&gt; &lt;samp&gt;Smith&#39;,&lt;/samp&gt; &lt;samp&gt;35000.00,&lt;/samp&gt; &lt;samp&gt;11,&lt;/samp&gt; &lt;samp&gt;&#39;Associate&#39;));&lt;/samp&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Nesse exemplo é recuperado o conteúdo das três colunas que têm valores atribuídos pelo DB2 no momento da inserção: EMPNO (IDENTIDY), HIREDATE e HIRETYPE (que tem cláusula DEFALUT)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;Os valores que podem ser recuperados nesse novo tipo de statement SQL são:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Valores de colunas que são resultados de uma expressão&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Colunas definidas como DEFAULT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Todos os valores de uma linha inserida, sem especificar o nome da coluna&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;os valores inseridos pela operação MULTI-&lt;/span&gt;&lt;st1:stockticker&gt;&lt;span lang=&quot;PT-BR&quot;&gt;ROW&lt;/span&gt;&lt;/st1:stockticker&gt;&lt;span lang=&quot;PT-BR&quot;&gt; INSERT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Valores que são alterados por um BEFORE TRIGGER&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;ListTahoma1&quot;&gt;&lt;span lang=&quot;PT-BR&quot;&gt;Valores que são gerados automaticamente, como ROWID ou INDETITY&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;Maiores Informações&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang=&quot;PT-BR&quot;   style=&quot;font-family:Arial;font-size:100%;&quot;&gt;Manual DB2 UDB for z/OS V8 SQL reference: &lt;a href=&quot;http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dsnsqj14/CCONTENTS&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dsnsqj14/CCONTENTS&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://db2mainframe.blogspot.com/feeds/7986961328252833285/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6831046906749359917/7986961328252833285' title='2 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6831046906749359917/posts/default/7986961328252833285'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6831046906749359917/posts/default/7986961328252833285'/><link rel='alternate' type='text/html' href='http://db2mainframe.blogspot.com/2007/12/melhorias-no-sql-do-db2-v8-zos.html' title='Melhorias no SQL do DB2 V8 z/OS'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6831046906749359917.post-8484412142041485685</id><published>2007-12-20T15:48:00.000-03:00</published><updated>2007-12-20T09:48:29.875-03:00</updated><title type='text'>Bem vindo ao Blog DB2 z/OS - O DB2 do Mainframe</title><content type='html'>&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Antes de qualquer coisa quero dar boas vindas a todos.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;A idéia desse blog é trazer novidades, soluções, dicas e tudo mais que for relacionado ao DB2 z/OS – o DB2 do Mainframe. E em português!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Todos nós sabemos que grande parte (e olha que tem bastante) do material relacionado ao DB2 e ao mainframe são escritos em inglês: Fóruns, comunidades, manuais, Redbooks. E, infelizmente, isso pode ser fator limitante para algumas pessoas em busca de conhecimento. Por isso começo esse blog hoje, para trazer as novidades, soluções e dicas que encontramos mundo a fora para a nossa língua.&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Aqui vocês irão encontrar traduções de alguns bons blogs estrangeiros, mais contribuições minhas e de quem desejar trocar informações. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Por isso são bem vindos comentários, sugestões e toda forma pró-ativa de contribuição. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot; lang=&quot;PT-BR&quot;&gt;Mais uma vez, sejam bem vindos e espero que aproveitem.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://db2mainframe.blogspot.com/feeds/8484412142041485685/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6831046906749359917/8484412142041485685' title='3 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6831046906749359917/posts/default/8484412142041485685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6831046906749359917/posts/default/8484412142041485685'/><link rel='alternate' type='text/html' href='http://db2mainframe.blogspot.com/2007/12/bem-vindo-ao-blog-db2-zos-o-db2-do.html' title='Bem vindo ao Blog DB2 z/OS - O DB2 do Mainframe'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry></feed>