<?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-393809595399109651</id><updated>2024-10-25T04:59:49.789-07:00</updated><title type='text'>             ## BANCO DE DADOS ##</title><subtitle type='html'>SELECT * FROM Busca_de_Conhecimento WHERE Tema LIKE &#39;% Banco de Dados %&#39; or Tema LIKE &#39;% Assuntos relacionados%&#39;</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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>181</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-393809595399109651.post-840924952786095652</id><published>2017-11-21T02:44:00.000-08:00</published><updated>2017-11-21T02:48:13.591-08:00</updated><title type='text'>Attach de um arquivo de Banco de dados apenas com MDF</title><content type='html'>&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;droid sans&amp;quot;, arial, sans-serif; font-stretch: inherit; line-height: inherit; padding: 0px 0px 20px; text-align: left; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;Blog: https://cristianojsantos.wordpress.com/&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 15.2px; text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: 15.2px;&quot;&gt;Normalmente faríamos este processo utilizando as seguintes sequências de telas:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem01.png&quot; style=&quot;border: 0px; color: #009bc2; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin-left: 1em; margin-right: 1em; margin-top: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;Imagem01&quot; class=&quot;aligncenter size-medium wp-image-176&quot; data-attachment-id=&quot;176&quot; data-comments-opened=&quot;1&quot; data-image-description=&quot;&quot; data-image-meta=&quot;{&amp;quot;aperture&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;credit&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;camera&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;caption&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;created_timestamp&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;copyright&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;focal_length&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;iso&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;shutter_speed&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;title&amp;quot;:&amp;quot;&amp;quot;}&quot; data-image-title=&quot;Imagem01&quot; data-large-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem01.png?w=380&quot; data-medium-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem01.png?w=267&quot; data-orig-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem01.png&quot; data-orig-size=&quot;380,427&quot; data-permalink=&quot;https://cristianojsantos.wordpress.com/2013/03/07/atachando-um-arquivo-de-banco-de-dados-mdf-sem-o-arquivo-de-log-no-sql-server/imagem01/&quot; height=&quot;300&quot; sizes=&quot;(max-width: 266px) 100vw, 266px&quot; src=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem01.png?w=266&amp;amp;h=300&quot; srcset=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem01.png?w=266&amp;amp;h=300 266w, https://cristianojsantos.files.wordpress.com/2013/03/imagem01.png?w=133&amp;amp;h=150 133w, https://cristianojsantos.files.wordpress.com/2013/03/imagem01.png 380w&quot; style=&quot;border: 0px; display: block; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; height: auto; line-height: inherit; margin: 20px auto; max-width: 100%; padding: 0px; vertical-align: baseline;&quot; width=&quot;266&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;Figura 1 – Selecionando a Opção de Attach no Banco de Dados&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; text-align: center; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem02.png&quot; style=&quot;border: 0px; color: #009bc2; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; text-decoration-line: none; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;Imagem02&quot; class=&quot;aligncenter size-medium wp-image-177&quot; data-attachment-id=&quot;177&quot; data-comments-opened=&quot;1&quot; data-image-description=&quot;&quot; data-image-meta=&quot;{&amp;quot;aperture&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;credit&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;camera&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;caption&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;created_timestamp&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;copyright&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;focal_length&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;iso&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;shutter_speed&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;title&amp;quot;:&amp;quot;&amp;quot;}&quot; data-image-title=&quot;Imagem02&quot; data-large-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem02.png?w=820&quot; data-medium-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem02.png?w=300&amp;amp;h=163&quot; data-orig-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem02.png&quot; data-orig-size=&quot;1325,625&quot; data-permalink=&quot;https://cristianojsantos.wordpress.com/2013/03/07/atachando-um-arquivo-de-banco-de-dados-mdf-sem-o-arquivo-de-log-no-sql-server/imagem02/&quot; src=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem02.png?w=300&amp;amp;h=163&quot; style=&quot;border: 0px; display: block; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; height: auto; line-height: inherit; margin: 20px auto; max-width: 100%; padding: 0px; vertical-align: baseline;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;Figura 2 – Selecionando o arquivo MDF do Banco de dados que iremos atachar.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; vertical-align: baseline;&quot;&gt;
Desta forma, ao selecionarmos nosso banco de dados, conforme veremos na Figura 3 abaixo, o mesmo somente terá o arquivo MDF sendo informado, onde, para o Arquivo de Log, aparece uma mensagem ao lado direito da indicação do caminho do arquivo, informando que o mesmo não fora localizado.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; vertical-align: baseline;&quot;&gt;
Se tivéssemos o arquivo LOG disponível no computador/servidor, bastaria somente informarmos seu local de origem.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem03.png&quot; style=&quot;border: 0px; color: #009bc2; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; text-decoration-line: none; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;Imagem03&quot; class=&quot;aligncenter size-medium wp-image-178&quot; data-attachment-id=&quot;178&quot; data-comments-opened=&quot;1&quot; data-image-description=&quot;&quot; data-image-meta=&quot;{&amp;quot;aperture&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;credit&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;camera&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;caption&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;created_timestamp&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;copyright&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;focal_length&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;iso&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;shutter_speed&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;title&amp;quot;:&amp;quot;&amp;quot;}&quot; data-image-title=&quot;Imagem03&quot; data-large-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem03.png?w=820&quot; data-medium-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem03.png?w=300&amp;amp;h=187&quot; data-orig-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem03.png&quot; data-orig-size=&quot;1012,632&quot; data-permalink=&quot;https://cristianojsantos.wordpress.com/2013/03/07/atachando-um-arquivo-de-banco-de-dados-mdf-sem-o-arquivo-de-log-no-sql-server/imagem03/&quot; sizes=&quot;(max-width: 300px) 100vw, 300px&quot; src=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem03.png?w=300&amp;amp;h=187&quot; srcset=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem03.png?w=300&amp;amp;h=187 300w, https://cristianojsantos.files.wordpress.com/2013/03/imagem03.png?w=600&amp;amp;h=374 600w, https://cristianojsantos.files.wordpress.com/2013/03/imagem03.png?w=150&amp;amp;h=94 150w&quot; style=&quot;border: 0px; display: block; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; height: auto; line-height: inherit; margin: 20px auto; max-width: 100%; padding: 0px; vertical-align: baseline;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; text-align: center; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;Figura 3 – Apresentando o arquivo MDF sem o Log informado.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; vertical-align: baseline;&quot;&gt;
Para resolvermos este problema, poderemos agir de duas formas, sendo a primeira:&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; vertical-align: baseline;&quot;&gt;
– Removendo via Tela do SSMS a informação do arquivo de Log, selecionando o mesmo na tela que estamos utilizando para atachar o arquivo, conforme a Figura 4 demostra.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem04.png&quot; style=&quot;border: 0px; color: #009bc2; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; text-decoration-line: none; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;Imagem04&quot; class=&quot;aligncenter size-medium wp-image-179&quot; data-attachment-id=&quot;179&quot; data-comments-opened=&quot;1&quot; data-image-description=&quot;&quot; data-image-meta=&quot;{&amp;quot;aperture&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;credit&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;camera&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;caption&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;created_timestamp&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;copyright&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;focal_length&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;iso&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;shutter_speed&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;title&amp;quot;:&amp;quot;&amp;quot;}&quot; data-image-title=&quot;Imagem04&quot; data-large-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem04.png?w=820&quot; data-medium-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem04.png?w=300&amp;amp;h=183&quot; data-orig-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem04.png&quot; data-orig-size=&quot;1104,632&quot; data-permalink=&quot;https://cristianojsantos.wordpress.com/2013/03/07/atachando-um-arquivo-de-banco-de-dados-mdf-sem-o-arquivo-de-log-no-sql-server/imagem04/&quot; src=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem04.png?w=300&amp;amp;h=183&quot; style=&quot;border: 0px; display: block; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; height: auto; line-height: inherit; margin: 20px auto; max-width: 100%; padding: 0px; vertical-align: baseline;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; text-align: center; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;Figura 4 – Removendo o arquivo de Log pelo SSMS&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; vertical-align: baseline;&quot;&gt;
– Executando uma query com a Procedure&amp;nbsp;&lt;span style=&quot;border: 0px; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;sp_attach_single_file_db,&amp;nbsp;&lt;/span&gt;que espera receber dois parâmetros:&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 1.3; list-style: none; margin: 0px 0px 20px; padding: 0px 0px 0px 30px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; list-style: square; margin: 5px 0px 0px; padding: 0px; vertical-align: baseline;&quot;&gt;@dbname nvarchar(128): Nome do Banco de Dados&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; list-style: square; margin: 5px 0px 0px; padding: 0px; vertical-align: baseline;&quot;&gt;@physname nvarchar(260): Caminho de origem do arquivo MDF do Banco de Dados&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; vertical-align: baseline;&quot;&gt;
No final, a query será interpretada da seguinte forma:&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;EXEC sp_attach_single_file_db @dbname=’AdventureWorksDW2012′,@physname=’D:\Software\SQL Server\MSSQL11.SQLBI01\MSSQL\DATA\AdventureWorksDW2012_Data.mdf’&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem05.png&quot; style=&quot;border: 0px; color: #009bc2; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; text-decoration-line: none; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;Imagem05&quot; class=&quot;aligncenter size-medium wp-image-180&quot; data-attachment-id=&quot;180&quot; data-comments-opened=&quot;1&quot; data-image-description=&quot;&quot; data-image-meta=&quot;{&amp;quot;aperture&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;credit&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;camera&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;caption&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;created_timestamp&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;copyright&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;focal_length&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;iso&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;shutter_speed&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;title&amp;quot;:&amp;quot;&amp;quot;}&quot; data-image-title=&quot;Imagem05&quot; data-large-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem05.png?w=820&quot; data-medium-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem05.png?w=300&amp;amp;h=140&quot; data-orig-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem05.png&quot; data-orig-size=&quot;1014,324&quot; data-permalink=&quot;https://cristianojsantos.wordpress.com/2013/03/07/atachando-um-arquivo-de-banco-de-dados-mdf-sem-o-arquivo-de-log-no-sql-server/imagem05/&quot; src=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem05.png?w=300&amp;amp;h=140&quot; style=&quot;border: 0px; display: block; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; height: auto; line-height: inherit; margin: 20px auto; max-width: 100%; padding: 0px; vertical-align: baseline;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; text-align: center; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;Figura 5 – Executando a query que irá atachar o banco de Dados AdventureWorksDW&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; vertical-align: baseline;&quot;&gt;
Após, o banco de dados será criado e já estará disponível no SSMS, conforme Figura 6 abaixo.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem06.png&quot; style=&quot;border: 0px; color: #009bc2; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; text-decoration-line: none; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;Imagem06&quot; class=&quot;aligncenter size-medium wp-image-181&quot; data-attachment-id=&quot;181&quot; data-comments-opened=&quot;1&quot; data-image-description=&quot;&quot; data-image-meta=&quot;{&amp;quot;aperture&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;credit&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;camera&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;caption&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;created_timestamp&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;copyright&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;focal_length&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;iso&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;shutter_speed&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;title&amp;quot;:&amp;quot;&amp;quot;}&quot; data-image-title=&quot;Imagem06&quot; data-large-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem06.png?w=346&quot; data-medium-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem06.png?w=290&quot; data-orig-file=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem06.png&quot; data-orig-size=&quot;346,358&quot; data-permalink=&quot;https://cristianojsantos.wordpress.com/2013/03/07/atachando-um-arquivo-de-banco-de-dados-mdf-sem-o-arquivo-de-log-no-sql-server/imagem06/&quot; height=&quot;300&quot; sizes=&quot;(max-width: 289px) 100vw, 289px&quot; src=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem06.png?w=289&amp;amp;h=300&quot; srcset=&quot;https://cristianojsantos.files.wordpress.com/2013/03/imagem06.png?w=289&amp;amp;h=300 289w, https://cristianojsantos.files.wordpress.com/2013/03/imagem06.png?w=145&amp;amp;h=150 145w, https://cristianojsantos.files.wordpress.com/2013/03/imagem06.png 346w&quot; style=&quot;border: 0px; display: block; font-family: inherit; font-size: 15.2px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; height: auto; line-height: inherit; margin: 20px auto; max-width: 100%; padding: 0px; vertical-align: baseline;&quot; width=&quot;289&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #777777; font-family: &amp;quot;Droid Sans&amp;quot;, arial, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; padding: 0px 0px 20px; text-align: center; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;Figura 6 – Banco de Dados criado e disponível no SQL Server&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/840924952786095652/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2017/11/attach-de-um-arquivo-de-banco-de-dados.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/840924952786095652'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/840924952786095652'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2017/11/attach-de-um-arquivo-de-banco-de-dados.html' title='Attach de um arquivo de Banco de dados apenas com MDF'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-4934774161979089882</id><published>2017-11-17T18:03:00.001-08:00</published><updated>2017-11-17T18:08:32.416-08:00</updated><title type='text'>O servidor SMTP requer uma conexão segura ou o cliente não foi autenticado</title><content type='html'>&lt;div style=&quot;background-color: white; font-family: arial, tahoma, helvetica, freesans, sans-serif; font-stretch: normal; font-weight: normal; line-height: normal; margin: 0.75em 0px 0px; position: relative;&quot;&gt;
Ao configurar o envio de email pelo sqlserver 2012 corretamente aparecia a seguinte mensagem de erro:&lt;/div&gt;
&lt;div class=&quot;post-body entry-content&quot; id=&quot;post-body-3941225120949254696&quot; itemprop=&quot;articleBody&quot; style=&quot;background-color: white; font-family: calibri; line-height: 1.4; position: relative; width: 520px;&quot;&gt;
&lt;div style=&quot;font-size: 13.2px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-size: 13.2px;&quot;&gt;
&lt;b&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Gmail Error :The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;
Message&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&quot;O servidor SMTP requer uma conexão segura ou o cliente não foi autenticado. A resposta do servidor foi: 5.5.1 Authentication Required. Learn more at&quot;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;string&lt;br /&gt;
&lt;br /&gt;
Depois de inúmeras tentativas descobri que o problema estava na própria configuração do&amp;nbsp;&lt;b&gt;gmail&lt;/b&gt;. Eles possuem uma configuração para&amp;nbsp;&lt;a href=&quot;https://www.google.com/settings/security/lesssecureapps&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;aplicativos &quot;menos&quot; seguros&lt;/span&gt;&lt;/a&gt;&amp;nbsp;conforme a imagem abaixo:&lt;br /&gt;
&lt;div style=&quot;font-size: 13.2px;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7rcNyWNTh7H1hmO80_5DtTlyMND31GSAGrFjNslJgdB5R6hfEzBQlTqUJMB5FdF1RiVxH8h_Z3zrYMkb0sIk01dtlWW5Ib2Xdrvel7BAZDa6hKdFCj5g4Z2LjUBWkrS3eGaMk6HcCpiJm/s1600/Capturar.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;244&quot; data-original-width=&quot;726&quot; height=&quot;214&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7rcNyWNTh7H1hmO80_5DtTlyMND31GSAGrFjNslJgdB5R6hfEzBQlTqUJMB5FdF1RiVxH8h_Z3zrYMkb0sIk01dtlWW5Ib2Xdrvel7BAZDa6hKdFCj5g4Z2LjUBWkrS3eGaMk6HcCpiJm/s640/Capturar.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/4934774161979089882/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2017/11/o-servidor-smtp-requer-uma-conexao.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/4934774161979089882'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/4934774161979089882'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2017/11/o-servidor-smtp-requer-uma-conexao.html' title='O servidor SMTP requer uma conexão segura ou o cliente não foi autenticado'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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/AVvXsEh7rcNyWNTh7H1hmO80_5DtTlyMND31GSAGrFjNslJgdB5R6hfEzBQlTqUJMB5FdF1RiVxH8h_Z3zrYMkb0sIk01dtlWW5Ib2Xdrvel7BAZDa6hKdFCj5g4Z2LjUBWkrS3eGaMk6HcCpiJm/s72-c/Capturar.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393809595399109651.post-3755988242370739069</id><published>2016-12-30T04:31:00.002-08:00</published><updated>2016-12-30T04:31:59.135-08:00</updated><title type='text'>Retirar Zeros a Esquerda com PostgreSQL</title><content type='html'>Exemplo:&lt;br /&gt;
&lt;br /&gt;
create table funcionarios&lt;br /&gt;
(&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;codigo character varying(10) not null,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;nome character varying(100) not null,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;salario numeric(15, 2)&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
insert into funcionarios (codigo, nome, salario) values (&#39;000232&#39;, &#39;Zorrilho&#39;, 672.40);&lt;br /&gt;
insert into funcionarios (codigo, nome, salario) values (&#39;000239&#39;, &#39;Graxaim&#39;, 672.40);&lt;br /&gt;
insert into funcionarios (codigo, nome, salario) values (&#39;001431&#39;, &#39;Lebre&#39;, 1402.46);&lt;br /&gt;
&lt;br /&gt;
select&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;trim(leading &#39;0&#39; from codigo) as codigo,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;nome,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;salario&lt;br /&gt;
from funcionarios;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/3755988242370739069/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2016/12/retirar-zeros-esquerda-com-postgresql.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/3755988242370739069'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/3755988242370739069'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2016/12/retirar-zeros-esquerda-com-postgresql.html' title='Retirar Zeros a Esquerda com PostgreSQL'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-7034334225186742497</id><published>2016-12-09T04:07:00.003-08:00</published><updated>2016-12-09T04:07:30.943-08:00</updated><title type='text'>Listar BUSCAS/SELECTs que já foram feitos a uma tabela.</title><content type='html'>&lt;div style=&quot;color: #333333; font-family: &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, sans-serif; font-size: 12px; text-align: justify;&quot;&gt;
SELECT sum(seq_scan+idx_scan) AS total_de_leituras&lt;br /&gt;FROM pg_stat_user_tables&lt;br /&gt;WHERE relname=’nome_da_tabela’;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, sans-serif; font-size: 12px; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, sans-serif; font-size: 12px; text-align: justify;&quot;&gt;
Obs.: Um select com um JOIN considera duas BUSCAS&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/7034334225186742497/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2016/12/listar-buscasselects-que-ja-foram.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/7034334225186742497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/7034334225186742497'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2016/12/listar-buscasselects-que-ja-foram.html' title='Listar BUSCAS/SELECTs que já foram feitos a uma tabela.'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-5490773991074546010</id><published>2016-12-09T04:04:00.003-08:00</published><updated>2016-12-09T04:04:42.318-08:00</updated><title type='text'>Lista as tabelas ligadas por chave estrangeira a uma determinada tabela.</title><content type='html'>&lt;span style=&quot;color: #333333; font-family: &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, sans-serif; font-size: 12.6px; text-align: justify;&quot;&gt;SELECT tab_pk.relname AS “tab PK”, tab_fk.relname AS “tab_FK”&lt;/span&gt;&lt;br style=&quot;color: #333333; font-family: &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, sans-serif; font-size: 12.6px; text-align: justify;&quot; /&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, sans-serif; font-size: 12.6px; text-align: justify;&quot;&gt;FROM pg_class tab_pk&lt;/span&gt;&lt;br style=&quot;color: #333333; font-family: &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, sans-serif; font-size: 12.6px; text-align: justify;&quot; /&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, sans-serif; font-size: 12.6px; text-align: justify;&quot;&gt;JOIN pg_constraint &amp;nbsp;&amp;nbsp;&amp;nbsp; ON&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;skimlinks-unlinked&quot; style=&quot;color: #333333; font-family: &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, sans-serif; font-size: 12.6px; text-align: justify;&quot;&gt;tab_pk.oid=pg_constraint.confrelid&lt;/span&gt;&lt;br style=&quot;color: #333333; font-family: &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, sans-serif; font-size: 12.6px; text-align: justify;&quot; /&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, sans-serif; font-size: 12.6px; text-align: justify;&quot;&gt;JOIN pg_class tab_fk&amp;nbsp; ON pg_constraint.conrelid=&lt;/span&gt;&lt;span class=&quot;skimlinks-unlinked&quot; style=&quot;color: #333333; font-family: &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, sans-serif; font-size: 12.6px; text-align: justify;&quot;&gt;tab_fk.oid&lt;/span&gt;&lt;br style=&quot;color: #333333; font-family: &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, sans-serif; font-size: 12.6px; text-align: justify;&quot; /&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, sans-serif; font-size: 12.6px; text-align: justify;&quot;&gt;and tab_fk.relname=’cliente’;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/5490773991074546010/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2016/12/lista-as-tabelas-ligadas-por-chave.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/5490773991074546010'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/5490773991074546010'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2016/12/lista-as-tabelas-ligadas-por-chave.html' title='Lista as tabelas ligadas por chave estrangeira a uma determinada tabela.'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-409354139597006708</id><published>2016-12-09T03:55:00.001-08:00</published><updated>2016-12-09T03:55:38.350-08:00</updated><title type='text'>work mem</title><content type='html'>&lt;div style=&quot;background-color: white; color: #333333; font-family: Verdana, &amp;quot;Lucida Grande&amp;quot;, Lucida, Helvetica, Arial, sans-serif; font-size: 13px; margin-bottom: 1em; padding: 0px; text-align: justify;&quot;&gt;
Quando algum processo pesado é executado, por exemplo a geracao de indices do drupal ou consultas que usam muito ORDER BY, um diretorio pgsql&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;temp será criado caso o uso da memoria setado na variavel WORK&lt;/em&gt;MEM seja execedido.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: Verdana, &amp;quot;Lucida Grande&amp;quot;, Lucida, Helvetica, Arial, sans-serif; font-size: 13px; margin-bottom: 1em; padding: 0px; text-align: justify;&quot;&gt;
Nestes caso o aconselhável é aumentar - perante monitoramento - o parametro WORK_MEM na sessão em que está executando a query ou rodando os indices.&lt;/div&gt;
&lt;pre class=&quot;code&quot; style=&quot;background-color: #f7f9fa; border: 1px dashed rgb(204, 204, 204); color: #333333; font-family: monospace, serif; font-size: 13px; margin-bottom: 1em; overflow: auto; padding: 0.5em; text-align: justify; width: auto !important;&quot;&gt;SET WORK_MEM TO &quot;64MB&quot;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: Verdana, &amp;quot;Lucida Grande&amp;quot;, Lucida, Helvetica, Arial, sans-serif; font-size: 13px; margin-bottom: 1em; padding: 0px; text-align: justify;&quot;&gt;
Esse valor é por consulta, se colocar um valor muito alto a máquina vai sentar bonito, procure um valor entre 64 e 128, monitorando o servidor para verificar o impacto.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/409354139597006708/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2016/12/work-mem.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/409354139597006708'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/409354139597006708'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2016/12/work-mem.html' title='work mem'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-998815567310677250</id><published>2016-12-08T16:59:00.000-08:00</published><updated>2016-12-08T16:59:25.120-08:00</updated><title type='text'>Listar tabelas de um BD em Postgresql</title><content type='html'>&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;SELECT * FROM pg_catalog.pg_tables&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;WHERE schemaname NOT IN (&#39;pg_catalog&#39;, &#39;information_schema&#39;, &#39;pg_toast&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;ORDER BY schemaname, tablename&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/998815567310677250/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2016/12/listar-tabelas-de-um-bd-em-postgresql.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/998815567310677250'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/998815567310677250'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2016/12/listar-tabelas-de-um-bd-em-postgresql.html' title='Listar tabelas de um BD em Postgresql'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-6514836267127034642</id><published>2016-05-16T05:46:00.000-07:00</published><updated>2016-05-16T05:47:10.448-07:00</updated><title type='text'>Postgresql - Formatar CPF com REGEXP_REPLACE</title><content type='html'>&lt;h3 class=&quot;post-title entry-title&quot; itemprop=&quot;name&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 22px; font-stretch: normal; margin: 0.75em 0px 0px; position: relative; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: 13.2px; line-height: 1.4;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;Neste artigo, vamos mostrar 3 exemplos de como utilizar a função &lt;/span&gt;REGEXP_REPLACE&lt;span style=&quot;font-weight: normal;&quot;&gt; para formatar o CPF.&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;post-body entry-content&quot; id=&quot;post-body-1562747841235281452&quot; itemprop=&quot;description articleBody&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 1.4; position: relative; width: 570px;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;b style=&quot;font-size: 13.2px; line-height: 1.4;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;1º Exemplo&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
Para formatar o CPF vamos utilizar a tabela &quot;tb_alunos&quot;, exibida na imagem a seguir:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj63h8XDen4zxXWyt1joUVh_8Bii4RTwlGSaq3GHb6EiCj6n1951JvHyCkpBPfwRI6nvmRj010JXq6szFYGK2A-W4tz2Mf9FwF5jtmyY7pThDBgGXP4fHwdyQBjSkqGFXZJCGtNsHSB_M/s1600/postgresql_regexp_replace_tabela_alunos.png&quot; imageanchor=&quot;1&quot; style=&quot;color: #888888; margin-left: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;83&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj63h8XDen4zxXWyt1joUVh_8Bii4RTwlGSaq3GHb6EiCj6n1951JvHyCkpBPfwRI6nvmRj010JXq6szFYGK2A-W4tz2Mf9FwF5jtmyY7pThDBgGXP4fHwdyQBjSkqGFXZJCGtNsHSB_M/s320/postgresql_regexp_replace_tabela_alunos.png&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 1px solid rgb(238, 238, 238); box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; padding: 5px; position: relative;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&amp;nbsp;&lt;b&gt;Solução&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeF2dvXOQskIYJTmVj5dfi-cae0lE2PAD4ns0RvBGG4eeJgYQZq1MU9gVFszieh1xh6E37xyEDdlaEvUy_wyYE8H6lWi1c4uHo3hpE7GuufTBLAlPoAFSk5MKsahJwnXOYCKAqdg4I2wU/s1600/postgresql_regexp_replace_ex_cpf.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; color: #888888; float: left; margin-bottom: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;308&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeF2dvXOQskIYJTmVj5dfi-cae0lE2PAD4ns0RvBGG4eeJgYQZq1MU9gVFszieh1xh6E37xyEDdlaEvUy_wyYE8H6lWi1c4uHo3hpE7GuufTBLAlPoAFSk5MKsahJwnXOYCKAqdg4I2wU/s640/postgresql_regexp_replace_ex_cpf.png&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 1px solid rgb(238, 238, 238); box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; padding: 5px; position: relative;&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b style=&quot;font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Observe que na função REGEXP_REPLACE:&lt;/span&gt;&lt;/div&gt;
&lt;ul style=&quot;color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; margin: 0.5em 0px; padding: 0px 2.5em; widows: auto;&quot;&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Utilizamos parenteses &quot;&lt;b&gt;( )&lt;/b&gt;&quot; para separar cada parte da string, neste caso o CPF;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;Utilizamos colchetes &amp;nbsp;&amp;nbsp;&quot;&lt;/span&gt;[ ]&lt;span style=&quot;font-weight: normal;&quot;&gt;&quot; para indicar quais os caracteres que iremos utilizar em cada parte, neste caso utilizamos caracteres numéricos de &quot;0&quot; até &quot;9&quot;, representados pela expressão&amp;nbsp;&lt;/span&gt;0-9&lt;/b&gt;;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Indicamos dentro das chaves &quot;&lt;b&gt;{}&lt;/b&gt;&quot; a quantidade&amp;nbsp;de dígitos que vamos utilizar;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Utilizamos contra-barra &quot;&lt;b&gt;\&lt;/b&gt;&quot; antes de cada parte criada;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
Após a execução da sentença, teremos o seguinte resultado:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh57v_N5PJgh6MHcPNw3AeloNCe7j_6re24HZuw4h5S7AgKt9DWEXXdfw4ANO_vZAc-_2K6nEOJT2Csx3VmhxMdK7xRNkrj0_bsL-JEx6m7nth9uA7UBWAdVQQQaXyfRk0U_45w1u0u4hc/s1600/postgresql_regexp_replace_result_cpf_formatado.png&quot; imageanchor=&quot;1&quot; style=&quot;color: #888888; margin-left: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh57v_N5PJgh6MHcPNw3AeloNCe7j_6re24HZuw4h5S7AgKt9DWEXXdfw4ANO_vZAc-_2K6nEOJT2Csx3VmhxMdK7xRNkrj0_bsL-JEx6m7nth9uA7UBWAdVQQQaXyfRk0U_45w1u0u4hc/s1600/postgresql_regexp_replace_result_cpf_formatado.png&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 1px solid rgb(238, 238, 238); box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; padding: 5px; position: relative;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&amp;nbsp;&lt;b&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;2&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;º Exemplo&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 13.2px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
Também podemos substituir a expressão &quot;&lt;b&gt;0-9&lt;/b&gt;&quot;&lt;b&gt;&amp;nbsp;&lt;/b&gt;que&amp;nbsp;indica a utilização de caracteres numéricos de 0 até 9,&lt;b&gt;&amp;nbsp;&lt;/b&gt;pela expressão&amp;nbsp;&lt;b&gt;[:digit:]&lt;/b&gt;. O resultado será o mesmo.&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;b&gt;Solução&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcRhBtOW-uObFinlV_fEwXQRUcsgxuPW4uF0HSe0fyHdsht2gVmkpNSBScDT-pdoOQdNccQaIXhKjlS6-Nz9dfpkHRTL-Sa7gpC3wZ2KiqDNScqGR2mJ1kSXOytwIP1BsyCj8I2gGpe2o/s1600/postgresql_regexp_replace_ex_2_cpf.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; color: #888888; float: left; margin-bottom: 1em; margin-right: 1em; text-align: left; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;173&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcRhBtOW-uObFinlV_fEwXQRUcsgxuPW4uF0HSe0fyHdsht2gVmkpNSBScDT-pdoOQdNccQaIXhKjlS6-Nz9dfpkHRTL-Sa7gpC3wZ2KiqDNScqGR2mJ1kSXOytwIP1BsyCj8I2gGpe2o/s400/postgresql_regexp_replace_ex_2_cpf.png&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 1px solid rgb(238, 238, 238); box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; padding: 5px; position: relative;&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
Após a execução da sentença, teremos o seguinte resultado:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh57v_N5PJgh6MHcPNw3AeloNCe7j_6re24HZuw4h5S7AgKt9DWEXXdfw4ANO_vZAc-_2K6nEOJT2Csx3VmhxMdK7xRNkrj0_bsL-JEx6m7nth9uA7UBWAdVQQQaXyfRk0U_45w1u0u4hc/s1600/postgresql_regexp_replace_result_cpf_formatado.png&quot; imageanchor=&quot;1&quot; style=&quot;color: #888888; margin-left: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh57v_N5PJgh6MHcPNw3AeloNCe7j_6re24HZuw4h5S7AgKt9DWEXXdfw4ANO_vZAc-_2K6nEOJT2Csx3VmhxMdK7xRNkrj0_bsL-JEx6m7nth9uA7UBWAdVQQQaXyfRk0U_45w1u0u4hc/s1600/postgresql_regexp_replace_result_cpf_formatado.png&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 1px solid rgb(238, 238, 238); box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; padding: 5px; position: relative;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;3º Exemplo&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 13.2px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
Para facilitar, podemos substituir a expressão &quot;&lt;b&gt;[&lt;/b&gt;&lt;b&gt;[:digit:]&lt;/b&gt;&lt;b&gt;]&lt;/b&gt;&quot;&lt;b&gt;&amp;nbsp;&lt;/b&gt;que&amp;nbsp;indica a utilização de caracteres numéricos de 0 até 9,&lt;b&gt;&amp;nbsp;&lt;/b&gt;pela expressão abreviada&amp;nbsp;&lt;b&gt;&quot;\d&quot;&lt;/b&gt;. O resultado será o mesmo.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;b style=&quot;font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;b&gt;Solução&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQwabfHfEmCdZV-ip3sukz1rN1n2l9qSfavnftTSHhCOblgtKZz8NugqCP4dieUHfkPdSEFdx4SFryAKJIJyg8ozlmx5lPelDsescslHn2HneR-ik_zjxdBI7TX6x6G8zcrDyyv_O3Nqw/s1600/postgresql_regexp_replace_ex_3_cpf.png&quot; imageanchor=&quot;1&quot; style=&quot;color: #888888; margin-left: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;191&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQwabfHfEmCdZV-ip3sukz1rN1n2l9qSfavnftTSHhCOblgtKZz8NugqCP4dieUHfkPdSEFdx4SFryAKJIJyg8ozlmx5lPelDsescslHn2HneR-ik_zjxdBI7TX6x6G8zcrDyyv_O3Nqw/s400/postgresql_regexp_replace_ex_3_cpf.png&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 1px solid rgb(238, 238, 238); box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; padding: 5px; position: relative;&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 13.2px;&quot;&gt;
&lt;b style=&quot;font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-size: 13.2px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 13.2px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 13.2px;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
Após a execução da sentença, teremos o seguinte resultado:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh57v_N5PJgh6MHcPNw3AeloNCe7j_6re24HZuw4h5S7AgKt9DWEXXdfw4ANO_vZAc-_2K6nEOJT2Csx3VmhxMdK7xRNkrj0_bsL-JEx6m7nth9uA7UBWAdVQQQaXyfRk0U_45w1u0u4hc/s1600/postgresql_regexp_replace_result_cpf_formatado.png&quot; imageanchor=&quot;1&quot; style=&quot;color: #888888; margin-left: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh57v_N5PJgh6MHcPNw3AeloNCe7j_6re24HZuw4h5S7AgKt9DWEXXdfw4ANO_vZAc-_2K6nEOJT2Csx3VmhxMdK7xRNkrj0_bsL-JEx6m7nth9uA7UBWAdVQQQaXyfRk0U_45w1u0u4hc/s1600/postgresql_regexp_replace_result_cpf_formatado.png&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 1px solid rgb(238, 238, 238); box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; padding: 5px; position: relative;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/6514836267127034642/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2016/05/postgresql-formatar-cpf-com.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/6514836267127034642'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/6514836267127034642'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2016/05/postgresql-formatar-cpf-com.html' title='Postgresql - Formatar CPF com REGEXP_REPLACE'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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/AVvXsEjj63h8XDen4zxXWyt1joUVh_8Bii4RTwlGSaq3GHb6EiCj6n1951JvHyCkpBPfwRI6nvmRj010JXq6szFYGK2A-W4tz2Mf9FwF5jtmyY7pThDBgGXP4fHwdyQBjSkqGFXZJCGtNsHSB_M/s72-c/postgresql_regexp_replace_tabela_alunos.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393809595399109651.post-4392835407714817807</id><published>2016-05-13T09:46:00.002-07:00</published><updated>2016-05-13T09:56:46.712-07:00</updated><title type='text'>COMANDOS PSQL</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;Além de realizar comandos SQL, o psql também inclui alguns comandos próprios. Por exemplo, para sair do psql, você deve usar o comando \q (note que é uma barra invertida mesmo).&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;Existem várias opções interessantes, veja alguns exemplos:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;\d: lista as tabelas do banco de dados&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;\dv: lista as views do banco de dados&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;\di: lista os índices do banco de dados&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;\db: lista as tablespaces&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;\l: lista os bancos de dados&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;\dg: lista as roles existentes (usuários ou grupos)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;\conninfo: apresenta informações sobre a conexão atual&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;\h: lista os comandos SQL&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;\h comando: apresenta detalhes sobre o comando&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;\dn: lista os esquemas do banco de dados&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;\c BASE: conecta a base&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;\d TABELA: apresenta a estrutura da tabela&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;Suponha que eu queira fazer uma conexão ao banco de dados &lt;b&gt;BANCO&lt;/b&gt;, com o usuário &lt;b&gt;USER&lt;/b&gt;, que fica no servidor 10.10.10.10&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: xx-small;&quot;&gt;
&lt;/span&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: xx-small;&quot;&gt;Para isto, eu deveria usar o comando:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif; font-size: xx-small;&quot;&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
# psql -h 10.10.10.10 -U &lt;b&gt;USER&lt;/b&gt;-d &lt;b&gt;BANCO&lt;/b&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;OU&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
# psql -U &lt;b&gt;USER&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
Se vc esquecer o usuário que está usando, basta usar o comando:&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
#select current_user;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small; text-align: justify;&quot;&gt;
É importante lembrar que o PostgreSQL faz subdivisões no banco de dados, os esquemas. Por padrão, o psql tenta se conectar primeiro a um esquema cujo nome seja igual ao do usuário.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-size: small; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small; text-align: justify;&quot;&gt;
Caso esse esquema não exista, o psql conecta-se ao esquema public. Se você quiser, por exemplo, se conectar ao esquema testes, deverá executar o comando:&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
#set search_path to &lt;b&gt;TESTE&lt;/b&gt;; (conecta ao esquema&amp;nbsp;&lt;b&gt;TESTE&lt;/b&gt;)&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/4392835407714817807/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2016/05/comandos-proprios-do-psql.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/4392835407714817807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/4392835407714817807'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2016/05/comandos-proprios-do-psql.html' title='COMANDOS PSQL'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-2155706127146040321</id><published>2016-03-26T21:31:00.003-07:00</published><updated>2016-03-26T21:31:38.295-07:00</updated><title type='text'>Criando Ranks no Postgres</title><content type='html'>&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;Vamos supor que você tenha a seguinte tabela:&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: white; clear: both; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: white; clear: both; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY4mHcLH-VtrsFNcySy5chA2MUtlJpP96YOb9kIr5lc4R3sjbhUUh1lhE8Fp1taqHGzYJNq_QbQt108hIfHRNu0rczIFIlbds9-mMc3_4TYdfNAkFRM4yB-IR2HPuWJ7OXX_9XOX3bPVM/s1600/table.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; color: #999999; float: left; margin-bottom: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;126&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY4mHcLH-VtrsFNcySy5chA2MUtlJpP96YOb9kIr5lc4R3sjbhUUh1lhE8Fp1taqHGzYJNq_QbQt108hIfHRNu0rczIFIlbds9-mMc3_4TYdfNAkFRM4yB-IR2HPuWJ7OXX_9XOX3bPVM/s400/table.png&quot; style=&quot;border: 1px solid rgb(204, 204, 204); padding: 4px;&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;E você tenha que ordená-la de acordo com os seguintes critérios: a maior média por departamento, seguido de maior nota a, maior nota b e finalmente maior nota c. Fica bem simples se usarmos a cláusula order by:&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 20.8px;&quot;&gt;SELECT department, name, grade_a, grade_b, grade_c&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 20.8px;&quot;&gt;FROM candidates&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 20.8px;&quot;&gt;ORDER BY department, ((grade_a + grade_b + grade_c) / 3) DESC,&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 20.8px;&quot;&gt;grade_a DESC, grade_b DESC, grade_c DESC&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;Resultado:&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: white; clear: both; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8d_oqNw8JgcvH202Zu0pixhp55HeEo6oapRmMH_bR1XNPzQ373NC2XJnrpXrBhkNjHLIIpyUppQRDXikDAzb1_1hIUz5z5ZH-2grLy0IgYI18QRAG9XdIUI6cT1uVcPkBK_SZ_DUvpgo/s1600/table_order_by.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; color: #999999; float: left; margin-bottom: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;127&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8d_oqNw8JgcvH202Zu0pixhp55HeEo6oapRmMH_bR1XNPzQ373NC2XJnrpXrBhkNjHLIIpyUppQRDXikDAzb1_1hIUz5z5ZH-2grLy0IgYI18QRAG9XdIUI6cT1uVcPkBK_SZ_DUvpgo/s400/table_order_by.png&quot; style=&quot;border: 1px solid rgb(204, 204, 204); padding: 4px;&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;Mas agora queremos criar uma qualificação indicando a posição do candidato de acordo com os critérios acima e esta posição deve ser relativa ao departamento que ele pertence, ou seja queremos saber os trê melhores qualificados no departamento &quot;Development&quot; e os três melhores no departamento &quot;Marketing&quot;. Talvez muitos já estejam pensando em usar sua linguagem de programação favorita para resolver este problema mas no Postgres temos as&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.postgresql.org/docs/8.4/static/tutorial-window.html&quot; style=&quot;background-color: white; color: #999999; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px; text-decoration: none;&quot;&gt;Window Functions&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;:&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 20.8px;&quot;&gt;SELECT department, name, grade_a, grade_b, grade_c,&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 20.8px;&quot;&gt;rank() OVER(PARTITION BY department ORDER BY ((grade_a + grade_b + grade_c) / 3) DESC, grade_a DESC, grade_b DESC, grade_c DESC)&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 20.8px;&quot;&gt;FROM candidates&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;Resultado:&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: white; clear: both; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm08gJB1J_-gfouw17yCXQX1T5eKK63_R64Iui9EDtVXtgKZj-9PPAy0FOObjOBtUItr204EvILZr98Lcfw8WIdvhSl_A3lzBRAN8JY3FPE9HUzu3EyT2CTEfudKlKBAtsfiUZuqexxAw/s1600/table_ranked.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; color: #999999; float: left; margin-bottom: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;118&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm08gJB1J_-gfouw17yCXQX1T5eKK63_R64Iui9EDtVXtgKZj-9PPAy0FOObjOBtUItr204EvILZr98Lcfw8WIdvhSl_A3lzBRAN8JY3FPE9HUzu3EyT2CTEfudKlKBAtsfiUZuqexxAw/s400/table_ranked.png&quot; style=&quot;border: 1px solid rgb(204, 204, 204); padding: 4px;&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;Legal, agora temos um número indicando a posição de cada candidato relativo ao seu departamento. Mas digamos agora que apenas os dois melhores candidatos de cada departamento devem ser retornados. Neste caso a seguinte query deve ser satisfatória:&lt;/span&gt;&lt;br /&gt;
&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 20.8px;&quot;&gt;SELECT *&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 20.8px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 20.8px;&quot;&gt;(SELECT department, name, grade_a, grade_b, grade_c,&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 20.8px;&quot;&gt;rank() OVER(PARTITION BY department ORDER BY ((grade_a + grade_b + grade_c) / 3) DESC, grade_a DESC, grade_b DESC, grade_c DESC)&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 20.8px;&quot;&gt;FROM candidates) AS sub_query&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 20.8px;&quot;&gt;WHERE rank &amp;lt; 3&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;Resultado:&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: white; clear: both; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDg_lJGjKUkYZ0EWet9xbycrRRTrQBRnX3SsVkvtEdzx39EQLmLnrOWAXhhuW2tKV7ggEZNIlAyhRUu0eNIUN69v9YfOtLGBQFfyPhiMKqTXfBlWw9A-Nfnqc35eKc7O6_vqOHzykk6p8/s1600/table_ranked_filtered.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; color: #999999; float: left; margin-bottom: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;86&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDg_lJGjKUkYZ0EWet9xbycrRRTrQBRnX3SsVkvtEdzx39EQLmLnrOWAXhhuW2tKV7ggEZNIlAyhRUu0eNIUN69v9YfOtLGBQFfyPhiMKqTXfBlWw9A-Nfnqc35eKc7O6_vqOHzykk6p8/s400/table_ranked_filtered.png&quot; style=&quot;border: 1px solid rgb(204, 204, 204); padding: 4px;&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/2155706127146040321/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2016/03/criando-ranks-no-postgres.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/2155706127146040321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/2155706127146040321'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2016/03/criando-ranks-no-postgres.html' title='Criando Ranks no Postgres'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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/AVvXsEhY4mHcLH-VtrsFNcySy5chA2MUtlJpP96YOb9kIr5lc4R3sjbhUUh1lhE8Fp1taqHGzYJNq_QbQt108hIfHRNu0rczIFIlbds9-mMc3_4TYdfNAkFRM4yB-IR2HPuWJ7OXX_9XOX3bPVM/s72-c/table.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393809595399109651.post-693366105558538194</id><published>2016-03-26T21:28:00.002-07:00</published><updated>2016-03-26T21:28:38.501-07:00</updated><title type='text'>Número de conexões PostgreSQL</title><content type='html'>&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;Comando:&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;select datname, count(*) from pg_stat_activity group by datname;&lt;/b&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;Com este comando podemos ver o número de conexões ativas no momento de execução agrupando-as pelo nome do banco de dados.&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;A saída será semelhante a isso:&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;&amp;nbsp;datname &amp;nbsp;| count&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;-----------+-------&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;testdb &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; 5&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;template1 | &amp;nbsp; &amp;nbsp; 1&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;(2 rows)&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;A tabela pg_stat_activity também tem outras colunas com outras informações interessantes:&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;datid&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;- oid do banco de dados&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;datname&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;- nome do banco de dados&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;procpid&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;- id do processo&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;usesysid&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;- OID do usuário&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;usename&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;- nome do usuário&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;current_query&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;- query sendo executada atualmente&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;waiting&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;- status de espera da query&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;xact_start&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;- horário em que a transação atual começou a executar&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;query_start&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;- horário em que a query começou a executar&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;backend_start&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;- horário em que o processo foi iniciado&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;client_addr&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;- Endereço do cliente&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;client_port&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;&amp;nbsp;- Porta do cliente&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px;&quot;&gt;As colunas que mostram informações sobre a query só podem ser vistas pelo super usuário ou se o usuário que estiver vendo as informações for o mesmo do processo que está sendo listado.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/693366105558538194/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2016/03/numero-de-conexoes-postgresql.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/693366105558538194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/693366105558538194'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2016/03/numero-de-conexoes-postgresql.html' title='Número de conexões PostgreSQL'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-4265110403998896772</id><published>2015-05-28T09:56:00.002-07:00</published><updated>2015-09-24T22:10:02.585-07:00</updated><title type='text'>Tipos de backup do PostgreSQL</title><content type='html'>&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
Diferentes maneiras de fazer backup dos bancos de dados do PostgreSQL.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background: rgb(255, 255, 255); border: 0px; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
O PostgreSQL possui varias formar de se fazer backup, podendo ser através de arquivos SQL, tar, ou customizado, além de poder fazer backup de apenas uma base ou todos de uma só vez, é para o caso de backups muito grandes a opção de dividir o arquivo em vários; vou mostrar as formas mais utilizadas de backup no PostgreSQL.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background: rgb(255, 255, 255); border: 0px; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
&lt;strong&gt;Backup de um único banco em formato SQL&lt;/strong&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
pg_dump -U usuario -d banco &amp;gt; backup.sql&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
&lt;strong&gt;Backup de um único banco em formato tar&lt;/strong&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
pg_dump -Ft -U usuario -d banco &amp;gt; backup.tar&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
&lt;strong&gt;Backup de um único banco em formato especifico do PostgreSQL&lt;/strong&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
pg_dump -Fc -U usuario -d banco &amp;gt; backup&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
Por padrão o pg_dump não faz backup de objeto grandes dentro do banco, para ativar esta opção é necessário utilizar a opção &quot;-b&quot; como por exemplo.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
&lt;strong&gt;Backup de um único banco em formato especifico e com objetos grandes&lt;/strong&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
pg_dump -Fc -b -U usuario -d banco &amp;gt; backup&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
&lt;strong&gt;Backup de uma única tabela de único banco&lt;/strong&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
pg_dump -Fc -b -U usuario -d banco -t nomedatabela &amp;gt; backup&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
&lt;strong&gt;Backup de todos os bancos do servidor&amp;nbsp;&lt;/strong&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
pg_dumpall -Fc -b -U usuario &amp;gt; backup&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
&lt;strong&gt;Backup remoto de um banco&lt;/strong&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
pg_dump -h hostremoto -d nomebanco | psql -h hostlocal -d banco&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
&lt;strong&gt;Backup em multivolumes (exemplo de volumes de 600MB)&lt;/strong&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
pg_dump nomebanco | split -m 600 nomearquivo&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
&lt;strong&gt;OBS: m para 1Mega, k para 1K, b para 512bytes&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.8999996185303px; margin-bottom: 10px; padding: 0px 5px;&quot;&gt;
Pessoalmente eu prefiro utilizar como backup o formato customizado com a opção dos blocos grandes ativados. &quot;-Fc -b&quot;, esse tipo de backup é mais rápido tanto na hora de fazer como na hora de voltar além de sair em um tamanho bem reduzido em relação aos demais.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/4265110403998896772/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/tipos-de-backup-do-postgresql.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/4265110403998896772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/4265110403998896772'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/tipos-de-backup-do-postgresql.html' title='Tipos de backup do PostgreSQL'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-2079585839682380926</id><published>2015-05-12T07:48:00.002-07:00</published><updated>2015-09-24T22:10:02.519-07:00</updated><title type='text'>Listando as 10 maiores tabelas no PostgreSQL</title><content type='html'>Para listar as maiores tabelas do seu banco de dados, utilize a consulta abaixo:&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
WITH table_stats AS (&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; SELECT&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; schemaname,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; tablename,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; pg_relation_size(schemaname || &#39;.&#39;|| tablename) as table_size,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; (pg_total_relation_size(schemaname || &#39;.&#39;|| tablename) - pg_relation_size(schemaname || &#39;.&#39;|| tablename)) as index_size,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; pg_total_relation_size(schemaname || &#39;.&#39;|| tablename) as total_size&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; FROM&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; pg_tables&lt;/div&gt;
&lt;div&gt;
)&lt;/div&gt;
&lt;div&gt;
SELECT&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; table_stats.schemaname,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; table_stats.tablename,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; pg_size_pretty(table_stats.table_size) as table_size,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; pg_size_pretty(table_stats.index_size) as index_size,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; pg_size_pretty(table_stats.total_size) as total_size&lt;/div&gt;
&lt;div&gt;
FROM&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; table_stats&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
WHERE&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; -- ajuste o filtro conforme sua necessidade!&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; table_stats.schemaname = &#39;public&#39;&lt;/div&gt;
&lt;div&gt;
ORDER BY&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; table_stats.total_size desc,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; table_stats.index_size desc,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; table_stats.table_size desc&lt;/div&gt;
&lt;div&gt;
LIMIT 10;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/2079585839682380926/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/listando-as-10-maiores-tabelas-no.html#comment-form' title='1 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/2079585839682380926'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/2079585839682380926'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/listando-as-10-maiores-tabelas-no.html' title='Listando as 10 maiores tabelas no PostgreSQL'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393809595399109651.post-6646763627257919805</id><published>2015-05-12T07:46:00.005-07:00</published><updated>2015-09-24T22:10:02.660-07:00</updated><title type='text'>Tamanho das tabelas no PostgreSQL</title><content type='html'>&lt;h2 style=&quot;background-color: white; color: #494949; font-family: Helvetica, Arial, sans-serif; font-size: 19.2000007629395px; font-weight: normal; line-height: 24.9599990844727px; margin: 0px; padding: 0px;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20.3999996185303px;&quot;&gt;Em muitos casos é preciso saber o espaço em que as tabelas do banco de dados estão utilizando em disco, para fins de monitoramento e decisão de estruturação de banco. Para tal tarefa no PostgreSQL o comando abaixo resolve o problema.&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20.3999996185303px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;content&quot; style=&quot;background-color: white; color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20.3999996185303px;&quot;&gt;
&lt;pre&gt;&lt;i&gt;SELECT esquema, tabela,
       pg_size_pretty(pg_relation_size(esq_tab)) AS tamanho,
       pg_size_pretty(pg_total_relation_size(esq_tab)) AS tamanho_total
  FROM (SELECT tablename AS tabela,
               schemaname AS esquema,
               schemaname||&#39;.&#39;||tablename AS esq_tab
          FROM pg_catalog.pg_tables
         WHERE schemaname NOT
            IN (&#39;pg_catalog&#39;, &#39;information_schema&#39;, &#39;pg_toast&#39;) ) AS x
 ORDER BY pg_total_relation_size(esq_tab) DESC;&lt;/i&gt;&lt;/pre&gt;
&lt;pre&gt;
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px; text-align: justify;&quot;&gt;
A coluna&amp;nbsp;&lt;i&gt;tamanho&lt;/i&gt;&amp;nbsp;mostra o tamanho que os registros (tuplas) da tabela está ocupando no disco, e a coluna&amp;nbsp;&lt;i&gt;tamanho_total&lt;/i&gt;&amp;nbsp;inclui também os&amp;nbsp;&lt;a href=&quot;http://pgdocptbr.sourceforge.net/pg80/storage-toast.html&quot; sl-processed=&quot;1&quot; style=&quot;color: #027ac6; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;TOASTs&lt;/a&gt;&amp;nbsp;e os índices associados à tabela.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px; text-align: justify;&quot;&gt;
Com essa consulta, é possível inclusive montar scripts (em shellscript, perl, python, groovy, etc..) de monitoramento do banco, por exemplo: caso a tabela tal, ou a soma de todas as tabelas chegar a X Mb, envie um email de alerta. Outra utilização seria de geração de indicadores para análise de tendência da expansão do banco.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/6646763627257919805/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/tamanho-das-tabelas-no-postgresql.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/6646763627257919805'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/6646763627257919805'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/tamanho-das-tabelas-no-postgresql.html' title='Tamanho das tabelas no PostgreSQL'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-6359989484420897015</id><published>2015-05-11T05:59:00.004-07:00</published><updated>2015-09-24T22:10:02.642-07:00</updated><title type='text'>Localizando e Excluindo Registros Duplicados</title><content type='html'>&lt;h3 class=&quot;post-title entry-title&quot; style=&quot;background-color: white; color: #4c4c4c; font-family: &#39;Droid Sans&#39;; font-size: 22px; font-stretch: normal; margin: 0px; position: relative;&quot;&gt;
&lt;br /&gt;&lt;/h3&gt;
&lt;div class=&quot;post-header&quot; style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 1.6; margin: 0px 0px 1em;&quot;&gt;
&lt;div class=&quot;post-header-line-1&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;post-body entry-content&quot; id=&quot;post-body-2010213733128236609&quot; style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 1.6; position: relative; width: 716px; word-spacing: 3px;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://paposql.blogspot.com.br/2014/01/localizando-e-excluindo-registros.html&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; color: #4d469c; float: left; margin-bottom: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuoAf7y7mKKt-grT9jPJ2q-OeowlJ1MMXfB6WC2_IWRypLDAqxhkPtAl_IMn2cpo8fXojTHC8RJTbL6I94qXhPVbAaYLIZ3BpzbEQRhlYxMARe2bV50mmfRENOP6ztq0-wYZ5KUt2zVh4/s1600/registros+duplicados.jpg&quot; style=&quot;-webkit-box-shadow: rgba(0, 0, 0, 0.2) 0px 0px 0px; background: transparent; border-radius: 0px; border: 1px solid transparent; box-shadow: rgba(0, 0, 0, 0.2) 0px 0px 0px; padding: 8px; position: relative;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Evitar a ocorrência de registros duplicados garante a integridade de um banco de dados, pra isso, planejar e prever situações no ato da modelagem do banco são imprescindíveis para não ter dor de cabeça.&lt;br /&gt;&lt;br /&gt;No entanto, é comum nos deparamos com bases de dados repletas de registros duplicados, o que pode ter ocorrido por conta de um mal planejamento ou, forçado devido a importação de dados externos.&lt;br /&gt;&lt;br /&gt;Localizar e eliminar estes registros, será o que veremos neste artigo.&lt;br /&gt;&lt;h2 style=&quot;border-bottom-color: transparent; border-bottom-style: solid; border-bottom-width: 1px; font-family: Calibri; font-size: 14px; font-stretch: normal; line-height: normal; margin: 0px -15px; padding: 0.6em 15px 0.5em; position: relative;&quot;&gt;
&lt;ul style=&quot;line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;&quot;&gt;
&lt;li style=&quot;border: none; margin: 0px 0px 0.25em; padding: 0.25em 0px;&quot;&gt;&lt;b style=&quot;color: #0b5394; font-size: x-large;&quot;&gt;Simulando Registros Duplicados&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/h2&gt;
A forma mais simples de localizar os duplicados é através dos comandos&amp;nbsp;&lt;i&gt;GROUP BY&lt;/i&gt;&amp;nbsp;e&amp;nbsp;&lt;i&gt;HAVING&lt;/i&gt;. Vamos popular uma tabela de produtos a fim de duplicar registros:&lt;br /&gt;&lt;pre style=&quot;background-color: #f0f0f0; border: 1px dashed rgb(204, 204, 204); font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; width: 708.828125px;&quot;&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; Create Table&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; produto (  
  id_produto &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;bigint not null&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;,  
  descricao &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;varchar &lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;(100),  
  estoque &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;int not null default&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; 0  
 ) ;&lt;/code&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f0f0f0; border: 1px dashed rgb(204, 204, 204); font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; width: 708.828125px;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;  &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Insert Into&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; produto    
  &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Values   &lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;
  (1, &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;Produto A&quot;&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;, 10),   
  (2, &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;Produto B&quot;&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;, 10),   
  (3, &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;Produto C&quot;&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;, 10),   
  (4, &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;Produto B&quot;&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;, 12),   
  (5, &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;Produto C&quot;&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;, 8),   
  (6, &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;Produto D&quot;&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;, 10),   
  (7, &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;Produto E&quot;&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;, 10),   
  (8, &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;Produto E&quot;&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;, 10),   
  (9, &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;Produto F&quot;&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;, 10);   
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 style=&quot;border-bottom-color: transparent; border-bottom-style: solid; border-bottom-width: 1px; font-family: Calibri; font-size: 14px; font-stretch: normal; line-height: normal; margin: 0px -15px; padding: 0.6em 15px 0.5em; position: relative;&quot;&gt;
&lt;ul style=&quot;line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;&quot;&gt;
&lt;li style=&quot;border: none; margin: 0px 0px 0.25em; padding: 0.25em 0px;&quot;&gt;&lt;b style=&quot;color: #0b5394; font-size: x-large;&quot;&gt;Identificando os Duplicados&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/h2&gt;
&lt;div style=&quot;border-top-color: rgb(238, 238, 238); border-top-style: solid; border-top-width: 1px; padding-top: 8px;&quot;&gt;
&lt;span style=&quot;line-height: 1.6;&quot;&gt;Vejam que os produtos B, C e E estão duplicados, vamos então&lt;/span&gt;&lt;span style=&quot;line-height: 1.6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a class=&quot;AdSpiderClass&quot; href=&quot;https://www.blogger.com/null&quot; id=&quot;spiderWordFound2&quot; rel=&quot;nofollow&quot; style=&quot;border-bottom-style: dotted !important; border-bottom-width: 1px !important; color: #f2551a; cursor: pointer !important; font-weight: 700 !important; line-height: 1.6;&quot;&gt;apresenta&lt;/a&gt;&lt;span style=&quot;line-height: 1.6;&quot;&gt;-los utilizando um simples select:&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #f0f0f0; border: 1px dashed rgb(204, 204, 204); font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; width: 708.828125px;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;select   &lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;
  *   
 &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;from  &lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;
   produto   
 &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;group by&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; descricao   
 &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;having &lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: magenta;&quot;&gt;count&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;(descricao) &amp;gt; 1 ;  
&lt;/code&gt;&lt;/pre&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; width: 708.828125px;&quot;&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt; id_produto descricao estoque  
 ---------- --------- -------  
      2 Produto B    10  
      3 Produto C    10  
      7 Produto E    10  
&lt;/code&gt;&lt;/pre&gt;
Localizar os registros foi possível pois, agrupamos os diferentes produtos em um só (group by), após, adicionamos a condição para que somente os registros que contenham mais de uma ocorrência (having...) fossem apresentados. (Mais de uma ocorrência após agrupado). No exemplo, filtramos somente os registros com mais de uma ocorrência, mas você pode especificar a quantidade desejada.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/6359989484420897015/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/localizando-e-excluindo-registros.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/6359989484420897015'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/6359989484420897015'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/localizando-e-excluindo-registros.html' title='Localizando e Excluindo Registros Duplicados'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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/AVvXsEjuoAf7y7mKKt-grT9jPJ2q-OeowlJ1MMXfB6WC2_IWRypLDAqxhkPtAl_IMn2cpo8fXojTHC8RJTbL6I94qXhPVbAaYLIZ3BpzbEQRhlYxMARe2bV50mmfRENOP6ztq0-wYZ5KUt2zVh4/s72-c/registros+duplicados.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393809595399109651.post-2954547618876664589</id><published>2015-05-11T05:50:00.001-07:00</published><updated>2015-09-24T22:10:02.533-07:00</updated><title type='text'>Alterar Schema de Tabela no PostgreSQL</title><content type='html'>&lt;h3 class=&quot;post-title entry-title&quot; style=&quot;background-color: white; color: #4c4c4c; font-family: &#39;Droid Sans&#39;; font-size: 22px; font-stretch: normal; margin: 0px; position: relative; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #444444; font-size: 14px; line-height: 1.6; word-spacing: 3px;&quot;&gt;Em sua configuração original, quando criamos uma tabela (&lt;/span&gt;&lt;span style=&quot;color: #444444; font-size: xx-small; word-spacing: 3px;&quot;&gt;ou qualquer outro objeto&lt;/span&gt;&lt;span style=&quot;color: #444444; font-size: 14px; line-height: 1.6; word-spacing: 3px;&quot;&gt;) no PostgreSQL sem especificar o schema que ela deve ficar, automaticamente o PG irá cria-lá no schema&lt;/span&gt;&lt;span style=&quot;color: #444444; font-size: 14px; line-height: 1.6; word-spacing: 3px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i style=&quot;color: #444444; font-size: 14px; line-height: 1.6; word-spacing: 3px;&quot;&gt;public&lt;/i&gt;&lt;span style=&quot;color: #444444; font-size: 14px; line-height: 1.6; word-spacing: 3px;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;post-body entry-content&quot; id=&quot;post-body-4979231520588593263&quot; style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 1.6; position: relative; text-align: justify; width: 716px; word-spacing: 3px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;post-body entry-content&quot; id=&quot;post-body-4979231520588593263&quot; style=&quot;background-color: white; position: relative; width: 716px;&quot;&gt;
&lt;div style=&quot;color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 1.6; text-align: justify; word-spacing: 3px;&quot;&gt;
&lt;span style=&quot;line-height: 1.6;&quot;&gt;Caso você necessite alterar o schema de suas tabelas, você pode realizar um alter table, através da seguinte&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 1.6; text-align: justify; word-spacing: 3px;&quot;&gt;
&lt;span style=&quot;line-height: 1.6;&quot;&gt;instrução SQL:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f0f0f0; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 1px dashed rgb(204, 204, 204); color: #444444; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: justify; width: 708.828125px; word-spacing: 3px;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;ALTER TABLE&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; SCHEMA.SUA_TABELA &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;SET SCHEMA&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; NOME_SCHEMA_DESTINO;  
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;spidertag style=&quot;color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 1.6; word-spacing: 3px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;line-height: 1.6;&quot;&gt;No exemplo, aponto o schema qual a tabela esta atualmente, desta forma posso estar&lt;/span&gt;&lt;span style=&quot;line-height: 1.6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a class=&quot;AdSpiderClass AdSpiderClassOver&quot; href=&quot;https://www.blogger.com/null&quot; id=&quot;spiderWordFound4&quot; rel=&quot;nofollow&quot; style=&quot;border-bottom-style: solid !important; border-bottom-width: 2px !important; color: #f2551a; cursor: pointer !important; font-weight: 700 !important; line-height: 1.6; text-decoration: underline !important;&quot;&gt;conectado&lt;/a&gt;&lt;span style=&quot;line-height: 1.6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;line-height: 1.6;&quot;&gt;a qualquer&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;line-height: 1.6;&quot;&gt;schema dentro do mesmo banco de dados que conseguirei realizar a mudança.&lt;/span&gt;&lt;/div&gt;
&lt;/spidertag&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/2954547618876664589/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/alterar-schema-de-tabela-no-postgresql.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/2954547618876664589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/2954547618876664589'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/alterar-schema-de-tabela-no-postgresql.html' title='Alterar Schema de Tabela no PostgreSQL'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-3816231421769532066</id><published>2015-05-11T05:48:00.000-07:00</published><updated>2015-09-24T22:10:02.567-07:00</updated><title type='text'>Como zerar um campo auto_increment no MySQL</title><content type='html'>&lt;span style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot;&gt;Você pode redefinir o valor do campo auto increment de duas formas, vejamos:&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot;&gt;1º - Através de Alter Table.&lt;/b&gt;&lt;br style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot; /&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: #444444; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; width: 708.828125px; word-spacing: 3px;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;ALTER TABLE&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; tabela &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;AUTO_INCREMENT &lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;= &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;1&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;;  
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: white; clear: both; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; text-align: center; word-spacing: 3px;&quot;&gt;
&lt;/div&gt;
&lt;br style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot; /&gt;&lt;b style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot;&gt;2º - Através de Truncate Table&amp;nbsp;&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot;&gt;(&lt;/span&gt;&lt;i style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot;&gt;&lt;b&gt;Cuidado com esta alternativa&lt;/b&gt;&lt;/i&gt;&lt;span style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot;&gt;)&lt;/span&gt;&lt;b style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot;&gt;.&lt;/b&gt;&lt;br style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot; /&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; widows: auto; width: 646.46875px;&quot;&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt; &lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;TRUNCATE TABLE&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt; tabela&lt;/code&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;;  
&lt;/code&gt;&lt;/pre&gt;
&lt;br style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot; /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #444444; font-family: &#39;Droid Sans&#39;; font-size: 14px; line-height: 22.3999996185303px; word-spacing: 3px;&quot;&gt;No primeiro caso os dados são mantidos em sua tabela, somente os valores do campo que você configurou como auto incremento serão atualizados, já no segundo caso toda sua tabela é apagada, por isso, somente execute este passo se realmente deseja reiniciar a numeração sem se importar com os dados, e o mais importante, não custa ter um backup da tabela.&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/3816231421769532066/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/como-zerar-um-campo-autoincrement-no.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/3816231421769532066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/3816231421769532066'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/como-zerar-um-campo-autoincrement-no.html' title='Como zerar um campo auto_increment no MySQL'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-3665054350871844844</id><published>2015-05-07T12:14:00.003-07:00</published><updated>2015-09-24T22:10:02.553-07:00</updated><title type='text'>Configurando Stream Replication No PostgreSQL 9</title><content type='html'>&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
Esse tutorial explica como configurar 2 servidores PosgreSQL como master e slave com stream replication, é bem simples.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
&lt;strong style=&quot;border: 0px none; list-style: none; margin: 0px; outline: none; padding: 0px;&quot;&gt;Cenário:&lt;/strong&gt;&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; margin: 0px 0px 25px 10px; outline: none; padding: 0px;&quot;&gt;
&lt;li style=&quot;border: 0px none; list-style: disc inside; margin: 0px 0px 5px; outline: none; padding: 0px;&quot;&gt;Master 192.168.1.200 (Debian 6 – PostgreSQL 9)&lt;/li&gt;
&lt;li style=&quot;border: 0px none; list-style: disc inside; margin: 0px 0px 5px; outline: none; padding: 0px;&quot;&gt;Slave 192.168.1.201 (Debian 6 – PostgreSQL 9)&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; margin: 0px; outline: none; padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
&lt;span id=&quot;more-25&quot; style=&quot;border: 0px none; list-style: none; margin: 0px; outline: none; padding: 0px;&quot;&gt;&lt;/span&gt;&lt;strong style=&quot;border: 0px none; list-style: none; margin: 0px; outline: none; padding: 0px;&quot;&gt;Configuração do Master:&amp;nbsp;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
No arquivo postgresql.conf, alterar as seguintes opções:&lt;/div&gt;
&lt;blockquote style=&quot;background: url(http://www.superdicas.blog.br/wp-content/themes/remal/images/quote.png) 0% 18px no-repeat rgb(255, 255, 255); border: 0px none; color: #333333; font-family: Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 12px; font-style: italic; line-height: 22px; list-style: none; margin: 0px 0px 30px 40px; min-height: 60px; outline: none; padding: 0px 0px 0px 60px;&quot;&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
listen_address = ‘*’ # Reponderá por qualquer ip cadastrado no server&lt;br /&gt;
wal_level = hot_standby&lt;br /&gt;
max_wal_senders = 1 # Número maximo de servidores slave&lt;br /&gt;
wal_keep_segments = 32&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
No arquivo pg_hba.conf, adicione o servidor slave para replicação:&lt;/div&gt;
&lt;blockquote style=&quot;background: url(http://www.superdicas.blog.br/wp-content/themes/remal/images/quote.png) 0% 18px no-repeat rgb(255, 255, 255); border: 0px none; color: #333333; font-family: Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 12px; font-style: italic; line-height: 22px; list-style: none; margin: 0px 0px 30px 40px; min-height: 60px; outline: none; padding: 0px 0px 0px 60px;&quot;&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
host &amp;nbsp; &amp;nbsp;replication &amp;nbsp; &amp;nbsp; postgres &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 192.168.1.201/32 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;trust&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
&lt;strong style=&quot;border: 0px none; list-style: none; margin: 0px; outline: none; padding: 0px;&quot;&gt;Configuração do Slave&amp;nbsp;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
Criar o arquivo recovery.conf no mesmo diretório do arquivo postgresql.conf, com o seguinte conteúdo:&lt;/div&gt;
&lt;blockquote style=&quot;background: url(http://www.superdicas.blog.br/wp-content/themes/remal/images/quote.png) 0% 18px no-repeat rgb(255, 255, 255); border: 0px none; color: #333333; font-family: Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 12px; font-style: italic; line-height: 22px; list-style: none; margin: 0px 0px 30px 40px; min-height: 60px; outline: none; padding: 0px 0px 0px 60px;&quot;&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
standby_mode = ‘on’&lt;br /&gt;
primary_conninfo = ‘host=192.168.1.200 port=5432 user=postgres’&lt;br /&gt;
trigger_file = ‘/tmp/pgsql.trigger’&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
&lt;strong style=&quot;border: 0px none; list-style: none; margin: 0px; outline: none; padding: 0px;&quot;&gt;Parar o PostgreSQL dos 2 servidores:&lt;/strong&gt;&lt;/div&gt;
&lt;blockquote style=&quot;background: url(http://www.superdicas.blog.br/wp-content/themes/remal/images/quote.png) 0% 18px no-repeat rgb(255, 255, 255); border: 0px none; color: #333333; font-family: Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 12px; font-style: italic; line-height: 22px; list-style: none; margin: 0px 0px 30px 40px; min-height: 60px; outline: none; padding: 0px 0px 0px 60px;&quot;&gt;
[postgres@server ~]$&amp;nbsp;/usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data/&lt;br /&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
&lt;/div&gt;
[postgres@client ~]$&amp;nbsp;/usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data/&lt;br /&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
Agora você deverá copiar todo o conteúdo do data do master para o data do slaver:&lt;/div&gt;
&lt;blockquote style=&quot;background: url(http://www.superdicas.blog.br/wp-content/themes/remal/images/quote.png) 0% 18px no-repeat rgb(255, 255, 255); border: 0px none; color: #333333; font-family: Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 12px; font-style: italic; line-height: 22px; list-style: none; margin: 0px 0px 30px 40px; min-height: 60px; outline: none; padding: 0px 0px 0px 60px;&quot;&gt;
[postgres@server ~]$&amp;nbsp;rsync -a -v -e ssh /usr/local/pgsql/data/ 192.168.1.201:/usr/local/pgsql/data/ –exclude postmaster.pid&lt;br /&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
E no&amp;nbsp;arquivo postgresql.conf do slave, alterar as seguintes opções:&lt;/div&gt;
&lt;blockquote style=&quot;background: url(http://www.superdicas.blog.br/wp-content/themes/remal/images/quote.png) 0% 18px no-repeat rgb(255, 255, 255); border: 0px none; color: #333333; font-family: Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 12px; font-style: italic; line-height: 22px; list-style: none; margin: 0px 0px 30px 40px; min-height: 60px; outline: none; padding: 0px 0px 0px 60px;&quot;&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
hot_standby = on&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
Agora você pode iniciar os 2 serviços do PostgreSQL:&lt;/div&gt;
&lt;blockquote style=&quot;background: url(http://www.superdicas.blog.br/wp-content/themes/remal/images/quote.png) 0% 18px no-repeat rgb(255, 255, 255); border: 0px none; color: #333333; font-family: Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 12px; font-style: italic; line-height: 22px; list-style: none; margin: 0px 0px 30px 40px; min-height: 60px; outline: none; padding: 0px 0px 0px 60px;&quot;&gt;
[postgres@server ~]$&amp;nbsp;/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data/&lt;br /&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
&lt;/div&gt;
[postgres@client ~]$&amp;nbsp;/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data/&lt;br /&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
Para verificar se a replicação está certa você pode ver assim:&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
No master:&lt;/div&gt;
&lt;blockquote style=&quot;background: url(http://www.superdicas.blog.br/wp-content/themes/remal/images/quote.png) 0% 18px no-repeat rgb(255, 255, 255); border: 0px none; color: #333333; font-family: Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 12px; font-style: italic; line-height: 22px; list-style: none; margin: 0px 0px 30px 40px; min-height: 60px; outline: none; padding: 0px 0px 0px 60px;&quot;&gt;
[postgres@server ~]$&amp;nbsp;ps ax | grep sender&lt;br /&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
1573 ? &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Ss &amp;nbsp; &amp;nbsp; 0:00 postgres: wal sender process postgres 192.168.1.201(53314) streaming 0/C0000D0&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
No slave:&lt;/div&gt;
&lt;blockquote style=&quot;background: url(http://www.superdicas.blog.br/wp-content/themes/remal/images/quote.png) 0% 18px no-repeat rgb(255, 255, 255); border: 0px none; color: #333333; font-family: Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 12px; font-style: italic; line-height: 22px; list-style: none; margin: 0px 0px 30px 40px; min-height: 60px; outline: none; padding: 0px 0px 0px 60px;&quot;&gt;
[postgres@server ~]$&amp;nbsp;ps ax | grep receiver&lt;br /&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
3180 ? &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Ss &amp;nbsp; &amp;nbsp; 0:00 postgres: wal receiver process &amp;nbsp; streaming 0/C0000D0&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
&lt;strong style=&quot;border: 0px none; list-style: none; margin: 0px; outline: none; padding: 0px;&quot;&gt;Testando a replicação:&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
No&amp;nbsp;&lt;strong style=&quot;border: 0px none; list-style: none; margin: 0px; outline: none; padding: 0px;&quot;&gt;master&lt;/strong&gt;&amp;nbsp;crie uma tabela teste e popule:&lt;/div&gt;
&lt;blockquote style=&quot;background: url(http://www.superdicas.blog.br/wp-content/themes/remal/images/quote.png) 0% 18px no-repeat rgb(255, 255, 255); border: 0px none; color: #333333; font-family: Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 12px; font-style: italic; line-height: 22px; list-style: none; margin: 0px 0px 30px 40px; min-height: 60px; outline: none; padding: 0px 0px 0px 60px;&quot;&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
postgres=# CREATE TABLE tabelaTeste (valor varchar(30));&lt;/div&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
postgres=# INSERT INTO tabelaTeste VALUES(‘teste1′);&lt;/div&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
postgres=# INSERT INTO tabelaTeste VALUES(‘teste2′);&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
Agora no server&amp;nbsp;&lt;strong style=&quot;border: 0px none; list-style: none; margin: 0px; outline: none; padding: 0px;&quot;&gt;slave&lt;/strong&gt;&amp;nbsp;(stand by) veja se a tabela “tabelaTeste| foi criada:&lt;/div&gt;
&lt;blockquote style=&quot;background: url(http://www.superdicas.blog.br/wp-content/themes/remal/images/quote.png) 0% 18px no-repeat rgb(255, 255, 255); border: 0px none; color: #333333; font-family: Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 12px; font-style: italic; line-height: 22px; list-style: none; margin: 0px 0px 30px 40px; min-height: 60px; outline: none; padding: 0px 0px 0px 60px;&quot;&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
postgres=# SELECT * FROM tabelaTeste;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;background-color: white; border: 0px none; color: #333333; font-family: &#39;Open Sans&#39;, Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
Se o resultado for esse abaixo, está correto:&lt;/div&gt;
&lt;blockquote style=&quot;background: url(http://www.superdicas.blog.br/wp-content/themes/remal/images/quote.png) 0% 18px no-repeat rgb(255, 255, 255); border: 0px none; color: #333333; font-family: Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 12px; font-style: italic; line-height: 22px; list-style: none; margin: 0px 0px 30px 40px; min-height: 60px; outline: none; padding: 0px 0px 0px 60px;&quot;&gt;
&lt;div style=&quot;border: 0px none; list-style: none; outline: none; padding: 1em 0px;&quot;&gt;
valor&lt;br /&gt;
—————&lt;br /&gt;
teste1&lt;br /&gt;
teste2&lt;br /&gt;
(2 rows)&lt;/div&gt;
&lt;/blockquote&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/3665054350871844844/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/configurando-stream-replication-no.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/3665054350871844844'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/3665054350871844844'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/configurando-stream-replication-no.html' title='Configurando Stream Replication No PostgreSQL 9'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-5100026757740040562</id><published>2015-05-05T06:32:00.000-07:00</published><updated>2015-09-24T22:10:02.609-07:00</updated><title type='text'>COMO RECUPERAR BANCO DO POSTGRES PELO DIRETÓRIO</title><content type='html'>&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;Pode acontecer de você precisar recuperar um banco de dados Postgres, mas tendo a seu dispor apenas uma cópia de um HD como backup, e não um arquivo de backup gerado com o comando&amp;nbsp;&lt;/span&gt;&lt;em style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;pg_dump&lt;/em&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;line-height: 20.3636360168457px;&quot;&gt;Neste caso, após algumas tentativas, consegui restaurar o banco e compartilho aqui o procedimento que funcionou comigo. Ou seja, recuperação do banco através dos diretórios.&lt;/span&gt;&lt;span style=&quot;line-height: 20.3636360168457px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/span&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;line-height: 20.3636360168457px;&quot;&gt;Antes de tudo, instale no servidor a versão do Postgres idêntica à versão instalada no backup.&lt;/span&gt;&lt;span style=&quot;line-height: 20.3636360168457px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/span&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;line-height: 20.3636360168457px;&quot;&gt;Depois, pare o serviço Postgres. No caso do Debian, onde a dica foi testada, executei:&lt;/span&gt;&lt;span style=&quot;line-height: 20.3636360168457px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: Courier; font-size: 16px; font-weight: 700; margin: 0px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: Courier; font-size: 16px; font-weight: 700; margin: 0px;&quot;&gt;# sh /etc/init.d/postgresql stop&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;Depois, copie do backup os seguintes diretórios, substituindo os mesmos diretórios no servidor atual. Por exemplo, usando o Postgres 9.3:&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.8em; list-style-image: url(http://img.vivaolinux.com.br/imagens/linux-arrow.gif); list-style-type: square; margin: 5px;&quot;&gt;
&lt;li style=&quot;border-radius: 0px !important; box-sizing: border-box; color: #555555;&quot;&gt;&lt;em style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot;&gt;/var/lib/postgresql/9.3&lt;/em&gt;&lt;/li&gt;
&lt;li style=&quot;border-radius: 0px !important; box-sizing: border-box; color: #555555;&quot;&gt;&lt;em style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot;&gt;/usr/share/postgresql/9.3&lt;/em&gt;&lt;/li&gt;
&lt;li style=&quot;border-radius: 0px !important; box-sizing: border-box; color: #555555;&quot;&gt;&lt;em style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot;&gt;/etc/postgresql/9.3&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;Obs.: recomendo renomear os diretórios originais para &quot;nome-backup&quot;, ao invés de simplesmente substituí-los.&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;É necessário dar permissão para um diretório, após a cópia para o servidor:&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;span style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: Courier; font-size: 16px; font-weight: 700; margin: 0px;&quot;&gt;# chmod 700 /var/lib/postgresql/9.3 -R&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;Inicialmente usei &quot;777&quot;, mas o próprio sistema informou que era para mudar para 700, quando tentei iniciar o serviço.&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;Depois inicie o serviço:&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;span style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: Courier; font-size: 16px; font-weight: 700; margin: 0px;&quot;&gt;# sh /etc/init.d/postgresql start&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;Pronto! Se tiver o&amp;nbsp;&lt;/span&gt;&lt;em style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;phpPgAdmin&lt;/em&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;&amp;nbsp;instalado, poderá acessá-lo para visualizar o banco, acessando:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.8em; list-style-image: url(http://img.vivaolinux.com.br/imagens/linux-arrow.gif); list-style-type: square; margin: 5px;&quot;&gt;
&lt;li style=&quot;border-radius: 0px !important; box-sizing: border-box; color: #555555;&quot;&gt;&lt;a href=&quot;http://localhost/phppgadmin/&quot; rel=&quot;nofollow&quot; style=&quot;background: 0px 0px; border-radius: 0px !important; box-sizing: border-box; color: #008318; outline: 0px !important; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;http://localhost/phppgadmin/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;Talvez exista uma forma mais fácil, mas essa foi a que eu encontrei.&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;Foi na base do comando&amp;nbsp;&lt;/span&gt;&lt;em style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;find&lt;/em&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;&amp;nbsp;que encontrei os referidos diretórios e fui copiando para o servidor.&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;Espero ajudar alguém na mesma situação.&lt;/span&gt;&lt;br style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;Abraço!&amp;nbsp;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/5100026757740040562/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/como-recuperar-banco-do-postgres-pelo.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/5100026757740040562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/5100026757740040562'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2015/05/como-recuperar-banco-do-postgres-pelo.html' title='COMO RECUPERAR BANCO DO POSTGRES PELO DIRETÓRIO'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-919156431579320293</id><published>2015-04-09T06:02:00.000-07:00</published><updated>2015-09-24T22:10:02.729-07:00</updated><title type='text'>CRIAÇÃO DE 1° SUPER USUÁRIO NO POSTGRESQL</title><content type='html'>&lt;div class=&quot;floatright&quot; style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; float: right; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px; padding: 5px; text-align: center;&quot;&gt;
&lt;ins class=&quot;adsbygoogle&quot; data-ad-client=&quot;ca-pub-3535276187000580&quot; data-ad-slot=&quot;2913193654&quot; data-adsbygoogle-status=&quot;done&quot; style=&quot;border-radius: 0px !important; box-sizing: border-box; display: inline-block; height: 280px; width: 336px;&quot;&gt;&lt;br /&gt;&lt;/ins&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border-radius: 0px !important; box-sizing: border-box; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.3636360168457px;&quot;&gt;
Depois de instalado seu SGBD postgres, como criar seu 1° usuário? Qual a senha de root? Qual a senha padrão?&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;Esta dica é para iniciantes.&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;Após a instalação dos seu PostgreSQL no&amp;nbsp;&lt;a href=&quot;http://www.vivaolinux.com.br/linux/&quot; style=&quot;background: 0px 0px; border-radius: 0px !important; box-sizing: border-box; color: #008318; outline: 0px !important; text-decoration: none;&quot;&gt;Linux&lt;/a&gt;, como criar seu 1° usuário para administração do banco?&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;Simples, na máquina com o banco instalado siga os seguintes passos.&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;Logue-se como root, tecle &quot;su root&quot; ou &quot;sudo -i&quot; no Ubuntu (no terminal a mensagem padrão deve terminar com #).&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;Entre como usuário postgres comando:&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;span style=&quot;border-radius: 0px !important; box-sizing: border-box; font-family: Courier; font-size: 16px; font-weight: 700; margin: 0px;&quot;&gt;# su postgres&lt;/span&gt;&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;Conecte no banco comando:&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;span style=&quot;border-radius: 0px !important; box-sizing: border-box; font-family: Courier; font-size: 16px; font-weight: 700; margin: 0px;&quot;&gt;$ psql&lt;/span&gt;&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;Agora deve aparecer a frase de boas vindas (Bem vindo ao psql...) e você está no terminal do posgres.&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;Entre com o comando:&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;span style=&quot;border-radius: 0px !important; box-sizing: border-box; font-family: Courier; font-size: 16px; font-weight: 700; margin: 0px;&quot;&gt;CREATE USER nomedousuario SUPERUSER INHERIT CREATEDB CREATEROLE;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;e tecle enter.&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;Depois entre com o comando:&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;span style=&quot;border-radius: 0px !important; box-sizing: border-box; font-family: Courier; font-size: 16px; font-weight: 700; margin: 0px;&quot;&gt;ALTER USER nomedousuario PASSWORD &#39;senha&#39;;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;e tecle enter.&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;Pronto! Usuário criado.&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;Agora para este usuário acessar o banco de outras máquinas da rede devemos liberar se acesso no arquivo&amp;nbsp;&lt;em style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot;&gt;pg_hba.conf&lt;/em&gt;&amp;nbsp;com o usuário root, siga os passos.&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;A localização deste arquivo varia segundo a distribuição Linux, no SUSE está em&amp;nbsp;&lt;em style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot;&gt;~postgres/data/pg_hba.conf&lt;/em&gt;, no Ubuntu está em&lt;em style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot;&gt;/etc/postgres/8.4/pg_hba.conf&lt;/em&gt;. Adicione a linha:&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;div class=&quot;codigo&quot; style=&quot;background-color: #fffff4; border-radius: 0px !important; border: 2px solid rgb(212, 212, 198) !important; box-sizing: border-box; padding: 15px;&quot;&gt;
host&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;all&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nomedousuario&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0/0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; password&lt;/div&gt;
&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;Para que seu usuário tenha acesso de qualquer máquina a todos os bancos de dados neste servidor.&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;Feito isso reinicie o postgres ou recarregue como o comando:&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;span style=&quot;border-radius: 0px !important; box-sizing: border-box; font-family: Courier; font-size: 16px; font-weight: 700; margin: 0px;&quot;&gt;# /etc/init.d/posgresql restart&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;ou&amp;nbsp;&lt;br style=&quot;border-radius: 0px !important; box-sizing: border-box;&quot; /&gt;&lt;span style=&quot;border-radius: 0px !important; box-sizing: border-box; font-family: Courier; font-size: 16px; font-weight: 700; margin: 0px;&quot;&gt;# /etc/init.d/posgresql reload&lt;/span&gt;&amp;nbsp;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/919156431579320293/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2015/04/criacao-de-1-super-usuario-no-postgresql.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/919156431579320293'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/919156431579320293'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2015/04/criacao-de-1-super-usuario-no-postgresql.html' title='CRIAÇÃO DE 1° SUPER USUÁRIO NO POSTGRESQL'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-8588736161797200686</id><published>2015-04-06T12:43:00.002-07:00</published><updated>2015-09-24T22:10:02.710-07:00</updated><title type='text'>INSTALANDO O POSTGRES 9.4 NO RHEL 7</title><content type='html'>&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Bitter, sans-serif; font-size: 14px; line-height: 28px; margin-bottom: 1.5em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Recentemente precisei instalar um Postgres DB em uma VM RHEL 7 para testes. Aproveitei para compartilhar os passos seguidos aqui no Blog. Esse passo a passo deve funcionar em qualquer Distro RHEL-&lt;em style=&quot;border: 0px; font-family: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;like&lt;/em&gt;: Fedora, Centos,&amp;nbsp;&lt;a href=&quot;https://www.scientificlinux.org/&quot; style=&quot;border: 0px; color: #759b22; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Scientific Linux&lt;/a&gt;, OEL, etc.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Bitter, sans-serif; font-size: 14px; line-height: 28px; margin-bottom: 1.5em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
A instalação é a mais básica possível, pois o propósito desse DB é apenas para testes e laboratórios. Nada de tuning ou personalização.&lt;br /&gt;
Instale os seguintes pacotes do repositório Postgresql.org oficial.&lt;/div&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;[rsoares@rhel7-server-1 ~]$ &lt;strong style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;border: 0px; color: blue; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;sudo&lt;/span&gt;&lt;/strong&gt; yum install http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-redhat94-9.4-1.noarch.rpm&lt;/pre&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;[rsoares@rhel7-server-1 ~]$ sudo yum groupinstall &quot;PostgreSQL Database Server 9.4 PGDG&quot;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Bitter, sans-serif; font-size: 14px; line-height: 28px; margin-bottom: 1.5em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Inicialize o Postgres DB.&lt;/div&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;sudo /usr/pgsql-9.4/bin/postgresql94-setup initdb&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Bitter, sans-serif; font-size: 14px; line-height: 28px; margin-bottom: 1.5em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Habilite e teste o serviço do Postgres.&lt;/div&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;[rsoares@rhel7-server-1 ~]$ sudo systemctl enable postgresql-9.4.service&lt;/pre&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;[rsoares@rhel7-server-1 ~]$ sudo systemctl start postgresql-9.4.service&lt;/pre&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;[rsoares@rhel7-server-1 ~]$ sudo systemctl stop postgresql-9.4.service&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Bitter, sans-serif; font-size: 14px; line-height: 28px; margin-bottom: 1.5em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Troque para o usuário de sistema do postgres.&lt;/div&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;[rsoares@rhel7-server-1 ~]$ sudo su - postgres&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Bitter, sans-serif; font-size: 14px; line-height: 28px; margin-bottom: 1.5em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Altere o&amp;nbsp;&lt;strong style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;pg_hba.conf&lt;/strong&gt;&amp;nbsp;(espécie de “firewall” do Postgres) para permitir o acesso externo através da rede da VM.&lt;/div&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;-bash-4.2$ vim /var/lib/pgsql/9.4/data/pg_hba.conf&lt;/pre&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;# TYPE DATABASE USER ADDRESS METHOD

# &quot;local&quot; is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 ident
&lt;strong style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;border: 0px; color: blue; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;host all all 192.168.122.0/24 md5
&lt;/span&gt;&lt;/strong&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Bitter, sans-serif; font-size: 14px; line-height: 28px; margin-bottom: 1.5em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Altere o binding do serviço para aceitar conexões em qualquer endereço IP da VM.&lt;/div&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;-bash-4.2$ vim /var/lib/pgsql/9.4/data/postgresql.conf
&lt;/pre&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

&lt;strong style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;border: 0px; color: blue; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;listen_addresses = &#39;*&#39; # what IP address(es) to listen on;
&lt;/span&gt;&lt;/strong&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Bitter, sans-serif; font-size: 14px; line-height: 28px; margin-bottom: 1.5em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Logout do postgres user.&lt;/div&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;Ctrl + D no terminal&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Bitter, sans-serif; font-size: 14px; line-height: 28px; margin-bottom: 1.5em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Reinicie o serviço postgres&lt;/div&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;[rsoares@rhel7-server-1 ~]$ sudo systemctl start postgresql-9.4.service
[rsoares@rhel7-server-1 ~]$ sudo systemctl status postgresql-9.4.service
postgresql-9.4.service - PostgreSQL 9.4 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.4.service; enabled)
Active: &lt;strong style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;border: 0px; color: #99cc00; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;active&lt;/span&gt;&lt;/strong&gt; (running) since Thu 2014-11-06 17:21:38 BRST; 1s ago
Process: 24832 ExecStop=/usr/pgsql-9.4/bin/pg_ctl stop -D ${PGDATA} -s -m fast (code=exited, status=0/SUCCESS)
Process: 25292 ExecStart=/usr/pgsql-9.4/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=0/SUCCESS)
Process: 25286 ExecStartPre=/usr/pgsql-9.4/bin/postgresql94-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 25296 (postgres)
CGroup: /system.slice/postgresql-9.4.service
├─25296 /usr/pgsql-9.4/bin/postgres -D /var/lib/pgsql/9.4/data
├─25297 postgres: logger process
├─25299 postgres: checkpointer process
├─25300 postgres: writer process
├─25301 postgres: wal writer process
├─25302 postgres: autovacuum launcher process
└─25303 postgres: stats collector process
&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Bitter, sans-serif; font-size: 14px; line-height: 28px; margin-bottom: 1.5em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Confira o binding do serviço na porta TCP padrão so Postgres (5432)&lt;/div&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;[rsoares@rhel7-server-1 ~]$ netstat -tanp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:55970 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
&lt;span style=&quot;border: 0px; color: blue; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN -&lt;/strong&gt;&lt;/span&gt;
tcp 0 0 192.168.122.65:22 192.168.122.1:39634 ESTABLISHED -
tcp6 0 0 ::1:25 :::* LISTEN -
tcp6 0 0 :::47021 :::* LISTEN -
tcp6 0 0 :::111 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:631 :::* LISTEN -
tcp6 0 0 :::5432 :::* LISTEN -
&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Bitter, sans-serif; font-size: 14px; line-height: 28px; margin-bottom: 1.5em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Crie um novo DB User&lt;/div&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;-bash-4.2$ createuser -d -l -P --interactive NEW_DB_USER
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #666666; font-family: Bitter, sans-serif; font-size: 14px; line-height: 28px; margin-bottom: 1.5em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Crie um novo Data Base&lt;/div&gt;
&lt;pre style=&quot;background: rgb(238, 238, 238); border: 0px; color: #666666; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 14px; line-height: 1.6; margin-bottom: 1.5em; max-width: 100%; outline: 0px; overflow: auto; padding: 20px; vertical-align: baseline;&quot;&gt;-bash-4.2$ createdb -e -O NEW_DB_USER NEW_DB &quot;New DataBase&quot;
CREATE DATABASE &quot;NEW_DB&quot; OWNER &quot;NEW_DB_USER&quot;;
COMMENT ON DATABASE &quot;NEW_DB&quot; IS &#39;New DataBase&#39;;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/8588736161797200686/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2015/04/instalando-o-postgres-9-no-rhel-7.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/8588736161797200686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/8588736161797200686'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2015/04/instalando-o-postgres-9-no-rhel-7.html' title='INSTALANDO O POSTGRES 9.4 NO RHEL 7'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-4663234119687227983</id><published>2015-04-02T11:05:00.003-07:00</published><updated>2015-09-24T22:10:02.594-07:00</updated><title type='text'>Paginando resultados com limit e offset</title><content type='html'>&lt;header class=&quot;page-header&quot; style=&quot;background-color: white; border: 0px; color: #848484; font-family: Helvetica, Arial, sans-serif; font-size: 13.0080003738403px; line-height: 22px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;h1 class=&quot;entry-title&quot; style=&quot;border: 0px; color: #252525; font-family: ubuntu, &#39;trebuchet ms&#39;, arial, helvetica; font-size: 1.5rem; font-weight: normal; line-height: 1.75rem; margin: 0px 0px 0.5rem; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #848484; font-family: Helvetica, Arial, sans-serif; font-size: 13.0080003738403px; line-height: 22px;&quot;&gt;Tanto o MySQL quanto o Postgresql suportam um recurso muito útil para paginação de resultados, chamado de OFFSET, normalmente utilizado com LIMIT.&lt;/span&gt;&lt;/h1&gt;
&lt;/header&gt;&lt;div class=&quot;entry-content clearfix&quot; style=&quot;background-color: white; border: 0px; color: #848484; font-family: Helvetica, Arial, sans-serif; font-size: 13.0080003738403px; line-height: 22px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div style=&quot;border: 0px; font-size: 13.0080003738403px; margin-bottom: 1.25rem; padding: 0px; vertical-align: baseline;&quot;&gt;
Neste post, veremos como utilizar o LIMIT e o OFFSET para paginar resultados de uma SQL.&lt;/div&gt;
&lt;div style=&quot;border: 0px; font-size: 13.0080003738403px; margin-bottom: 1.25rem; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span id=&quot;more-458&quot; style=&quot;border: 0px; font-size: 13.0080003738403px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;border: 0px; font-size: 13.0080003738403px; margin-bottom: 1.25rem; padding: 0px; vertical-align: baseline;&quot;&gt;
A cláusula LIMIT é utilizada para limitar o número de resultados de uma SQL. Então, se sua SQL retornar 1000 linhas, mas você quer apenas as 10 primeiras, você deve executar uma instrução mais ou menos assim:&lt;/div&gt;
&lt;div style=&quot;border: 0px; font-size: 13.0080003738403px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter  sql&quot; id=&quot;highlighter_730428&quot; style=&quot;border: 0px; font-size: 1em !important; margin: 1em 0px !important; overflow-x: auto !important; overflow-y: hidden !important; padding: 0px; position: relative !important; vertical-align: baseline; width: 770px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-collapse: collapse; border-radius: 0px !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; max-width: 100%; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; table-layout: auto !important; top: auto !important; vertical-align: baseline !important; width: 770px;&quot;&gt;&lt;tbody style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;gutter&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border-right-color: rgb(108, 226, 108) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
1&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 740px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;sql keyword&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;SELECT&lt;/code&gt; &lt;code class=&quot;sql plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;coluna &lt;/code&gt;&lt;code class=&quot;sql keyword&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;FROM&lt;/code&gt; &lt;code class=&quot;sql plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;tabela LIMIT 10;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;border: 0px; font-size: 13.0080003738403px; margin-bottom: 1.25rem; padding: 0px; vertical-align: baseline;&quot;&gt;
Agora, vamos supor que você quer somente os resultados de 11 a 20. Com a instrução OFFSET fica fácil, basta proceder da seguinte forma:&lt;/div&gt;
&lt;div style=&quot;border: 0px; font-size: 13.0080003738403px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter  sql&quot; id=&quot;highlighter_552789&quot; style=&quot;border: 0px; font-size: 1em !important; margin: 1em 0px !important; overflow-x: auto !important; overflow-y: hidden !important; padding: 0px; position: relative !important; vertical-align: baseline; width: 770px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-collapse: collapse; border-radius: 0px !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; max-width: 100%; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; table-layout: auto !important; top: auto !important; vertical-align: baseline !important; width: 770px;&quot;&gt;&lt;tbody style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;gutter&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border-right-color: rgb(108, 226, 108) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
1&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 740px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;sql keyword&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;SELECT&lt;/code&gt; &lt;code class=&quot;sql plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;coluna &lt;/code&gt;&lt;code class=&quot;sql keyword&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;FROM&lt;/code&gt; &lt;code class=&quot;sql plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;tabela LIMIT 10 OFFSET 10;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;border: 0px; font-size: 13.0080003738403px; margin-bottom: 1.25rem; padding: 0px; vertical-align: baseline;&quot;&gt;
O comando OFFSET indica o início da leitura, e o LIMIT o máximo de registros a serem lidos. Para os registros de 61 a 75, por exemplo:&lt;/div&gt;
&lt;div style=&quot;border: 0px; font-size: 13.0080003738403px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter  sql&quot; id=&quot;highlighter_827079&quot; style=&quot;border: 0px; font-size: 1em !important; margin: 1em 0px !important; overflow-x: auto !important; overflow-y: hidden !important; padding: 0px; position: relative !important; vertical-align: baseline; width: 770px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-collapse: collapse; border-radius: 0px !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; max-width: 100%; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; table-layout: auto !important; top: auto !important; vertical-align: baseline !important; width: 770px;&quot;&gt;&lt;tbody style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;gutter&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border-right-color: rgb(108, 226, 108) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
1&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 740px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;sql keyword&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;SELECT&lt;/code&gt; &lt;code class=&quot;sql plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;coluna &lt;/code&gt;&lt;code class=&quot;sql keyword&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;FROM&lt;/code&gt; &lt;code class=&quot;sql plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;tabela LIMIT 15 OFFSET 60;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;border: 0px; font-size: 13.0080003738403px; margin-bottom: 1.25rem; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;
Com este recurso, fica fácil paginar os resultados de uma SQL e mostrar ao usuário apenas a página, ao invés de retornar todos os registros da tabela. Uma tabela com 2000 registros, por exemplo, fica muito melhor mostrar ao usuário de 10 em 10, por exemplo, e diminui a carga no banco de dados, melhorando a sua performance.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/4663234119687227983/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2015/04/paginando-resultados-com-limit-e-offset.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/4663234119687227983'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/4663234119687227983'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2015/04/paginando-resultados-com-limit-e-offset.html' title='Paginando resultados com limit e offset'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-6943899144829187261</id><published>2015-03-25T11:14:00.003-07:00</published><updated>2015-09-24T22:10:02.668-07:00</updated><title type='text'>Alterando Tablespace de Tabelas e Indices no PostgreSQL</title><content type='html'>&lt;small class=&quot;date&quot; style=&quot;background-color: white; border-left-color: silver; border-left-style: solid; border-left-width: 1px; color: silver; float: right; font-family: &#39;Lucida Grande&#39;, &#39;Lucida Sans Unicode&#39;, Arial, sans-serif; font-size: 0.8em; line-height: 2.3em; margin: 1.5em 0px 5px 10px; padding-left: 5px; position: relative; right: 0px; text-align: center;&quot;&gt;&lt;span class=&quot;date_day&quot; style=&quot;display: block; font-size: 3em; text-align: right;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;date_month&quot; style=&quot;display: block; font-size: 3em; font-weight: bold; text-align: right;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;date_year&quot; style=&quot;display: block; font-size: 1.4em; line-height: 0.9em;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/small&gt;&lt;br /&gt;
&lt;div class=&quot;entry&quot; style=&quot;background-color: white; font-family: &#39;Lucida Grande&#39;, &#39;Lucida Sans Unicode&#39;, Arial, sans-serif; font-size: 11.6639995574951px; margin: 0px; text-align: justify;&quot;&gt;
&lt;div style=&quot;margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;b style=&quot;font-family: arial, sans-serif; font-size: 11.6639995574951px;&quot;&gt;ALTERANDO AS TABELAS&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: #00ae00;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;b&gt;– Cria TableSpace&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;CREATE TABLESPACE “banco_data” OWNER postgres LOCATION ‘/postgres/pg825/dados/pg_tblspc/banco_data&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: #00ae00;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;b&gt;– verifica se as tablespaces foram criadas&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT spcname AS “Tablespace”,&lt;br /&gt;pg_size_pretty(pg_tablespace_size (spcname)) AS “Tamanho”,&lt;br /&gt;spclocation as “Caminho”&lt;br /&gt;FROM pg_tableSpace;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: #00ae00;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;b&gt;– Gera Script para alterar tabelas&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT ‘ALTER TABLE’ ,n.nspname AS schemaname,’.’, c.relname AS tablename, ‘SET TABLESPACE banco_data;’&lt;br /&gt;FROM pg_class c&lt;br /&gt;LEFT JOIN pg_namespace n ON n.oid = c.relnamespace&lt;br /&gt;LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace&lt;br /&gt;WHERE c.relkind = ‘r&#39;::”char”&lt;br /&gt;AND nspname NOT IN&lt;br /&gt;(‘dbateste’,’information_schema’,’pg_catalog’,’pg_temp_1′,’pg_toast’,’postgres’,’publico’,’public’)&lt;br /&gt;ORDER BY n.nspname&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: #00ae00;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;b&gt;– Confere alteracao das tabelas&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT n.nspname AS schemaname, c.relname AS tablename, t.spcname AS “Tablespace”&lt;br /&gt;FROM pg_class c&lt;br /&gt;LEFT JOIN pg_namespace n ON n.oid = c.relnamespace&lt;br /&gt;LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace&lt;br /&gt;WHERE c.relkind = ‘r&#39;::”char”&lt;br /&gt;AND nspname NOT IN&lt;br /&gt;(‘dbateste’,’information_schema’,’pg_catalog’,’pg_temp_1′,’pg_toast’,’postgres’,’publico’,’public’)&lt;br /&gt;ORDER BY n.nspname, c.relname&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style=&quot;margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: #00ae00;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;b&gt;– Verifica tabelas sem tablespace&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT n.nspname AS schemaname, c.relname AS tablename, t.spcname AS “Tablespace”&lt;br /&gt;FROM pg_class c&lt;br /&gt;LEFT JOIN pg_namespace n ON n.oid = c.relnamespace&lt;br /&gt;LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace&lt;br /&gt;WHERE c.relkind = ‘r&#39;::”char”&lt;br /&gt;AND nspname NOT IN&lt;br /&gt;(‘dbateste’,’information_schema’,’pg_catalog’,’pg_temp_1′,’pg_toast’,’postgres’,’publico’,’public’)&lt;br /&gt;AND t.spcname IS NULL&lt;br /&gt;ORDER BY t.spcname DESC&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00ae00;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;b&gt;– Verifica tamanho da tablespace&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT spcname AS “Tablespace”,&lt;br /&gt;pg_size_pretty(pg_tablespace_size (spcname)) AS “Tamanho”,&lt;br /&gt;spclocation as “Caminho”&lt;br /&gt;FROM pg_tableSpace;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;font-family: arial, sans-serif;&quot;&gt;&lt;b&gt;ALTERANDO OS INDICES&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: #00ae00;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;b&gt;– Cria TableSpace&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;CREATE TABLESPACE “banco_idx” OWNER postgres LOCATION ‘/postgres/pg825/dados/pg_tblspc/banco_idx&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: #00ae00;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;b&gt;– verifica se as tablespaces foram criadas&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT spcname AS “Tablespace”,&lt;br /&gt;pg_size_pretty(pg_tablespace_size (spcname)) AS “Tamanho”,&lt;br /&gt;spclocation as “Caminho”&lt;br /&gt;FROM pg_tableSpace;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: #00ae00;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;b&gt;– Verifica quais sao os indices ( Nao primarios) e o tamanho&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT n.nspname AS schemaname,c.relname AS tablename,&lt;br /&gt;c.relpages::numeric * 4.096 / 1024::numeric AS espaco_mb&lt;br /&gt;FROM pg_class c&lt;br /&gt;LEFT JOIN pg_namespace n ON n.oid = c.relnamespace&lt;br /&gt;LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace&lt;br /&gt;LEFT JOIN pg_index x ON x.indexrelid = c.oid&lt;br /&gt;WHERE c.relkind = ‘i&#39;::”char”&lt;br /&gt;AND x.indisprimary != ‘t’&lt;br /&gt;AND x.indisunique != ‘t’&lt;br /&gt;AND nspname NOT IN&lt;br /&gt;(‘dbateste’,’information_schema’,’pg_catalog’,’pg_temp_1′,’pg_toast’,’postgres’,’publico’,’public’)&lt;br /&gt;ORDER BY n.nspname&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: #00ae00;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;b&gt;– Gera Script para alterar indices&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT ‘ALTER INDEX’, n.nspname AS schemaname , ‘.’ ,c.relname AS tablename, ‘SET TABLESPACE banco_idx;’&lt;br /&gt;FROM pg_class c&lt;br /&gt;LEFT JOIN pg_namespace n ON n.oid = c.relnamespace&lt;br /&gt;LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace&lt;br /&gt;LEFT JOIN pg_index x ON x.indexrelid = c.oid&lt;br /&gt;WHERE c.relkind = ‘i&#39;::”char”&lt;br /&gt;AND x.indisprimary != ‘t’&lt;br /&gt;AND x.indisunique != ‘t’&lt;br /&gt;AND nspname NOT IN&lt;br /&gt;(‘dbateste’,’information_schema’,’pg_catalog’,’pg_temp_1′,’pg_toast’,’postgres’,’publico’,’public’)&lt;br /&gt;ORDER BY n.nspname&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: #00ae00;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;b&gt;– Confere alteracao dos indices&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT n.nspname AS schemaname ,c.relname AS tablename,t.spcname AS “Tablespace”&lt;br /&gt;FROM pg_class c&lt;br /&gt;LEFT JOIN pg_namespace n ON n.oid = c.relnamespace&lt;br /&gt;LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace&lt;br /&gt;LEFT JOIN pg_index x ON x.indexrelid = c.oid&lt;br /&gt;WHERE c.relkind = ‘i&#39;::”char”&lt;br /&gt;AND x.indisprimary != ‘t’&lt;br /&gt;AND x.indisunique != ‘t’&lt;br /&gt;AND nspname NOT IN&lt;br /&gt;(‘dbateste’,’information_schema’,’pg_catalog’,’pg_temp_1′,’pg_toast’,’postgres’,’publico’,’public’)&lt;br /&gt;ORDER BY n.nspname&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: #00ae00;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;b&gt;– Verifica indice sem tablespace&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT n.nspname AS schemaname ,c.relname AS tablename,t.spcname AS “Tablespace”&lt;br /&gt;FROM pg_class c&lt;br /&gt;LEFT JOIN pg_namespace n ON n.oid = c.relnamespace&lt;br /&gt;LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace&lt;br /&gt;LEFT JOIN pg_index x ON x.indexrelid = c.oid&lt;br /&gt;WHERE c.relkind = ‘i&#39;::”char”&lt;br /&gt;AND x.indisprimary != ‘t’&lt;br /&gt;AND x.indisunique != ‘t’&lt;br /&gt;AND nspname NOT IN&lt;br /&gt;(‘dbateste’,’information_schema’,’pg_catalog’,’pg_temp_1′,’pg_toast’,’postgres’,’publico’,’public’)&lt;br /&gt;AND t.spcname IS NULL&lt;br /&gt;ORDER BY t.spcname DESC&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00ae00;&quot;&gt;&lt;span style=&quot;font-family: Courier 10 Pitch;&quot;&gt;&lt;b&gt;– Verifica tamanho da tablespace&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;western&quot; style=&quot;margin-top: 1em;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT spcname AS “Tablespace”,&lt;br /&gt;pg_size_pretty(pg_tablespace_size (spcname)) AS “Tamanho”,&lt;br /&gt;spclocation as “Caminho”&lt;br /&gt;FROM pg_tableSpace;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/6943899144829187261/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2015/03/alterando-tablespace-de-tabelas-e.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/6943899144829187261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/6943899144829187261'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2015/03/alterando-tablespace-de-tabelas-e.html' title='Alterando Tablespace de Tabelas e Indices no PostgreSQL'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-3797489419562651376</id><published>2015-02-10T10:45:00.001-08:00</published><updated>2015-09-24T22:10:02.562-07:00</updated><title type='text'>Upgrade de PostgreSQL 9.3 para 9.4 (em CentOS 7)</title><content type='html'>&lt;pre style=&quot;background-color: #f7f7f7; border-radius: 5px; border: 1px solid rgb(221, 221, 221); font-family: &#39;Courier New&#39;, Courier, Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13.9200000762939px; line-height: 1.5em; margin-bottom: 1.5em; margin-top: 1.5em; outline: 0px; overflow: auto; padding: 1em;&quot;&gt;[root@localhost ~]# &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;su - postgres&lt;/strong&gt;
Last login: Thu Dec 25 04:31:05 EST 2014 on pts/0
-bash-4.2$ &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;pg_dumpall &amp;gt; backup.sql&lt;/strong&gt;
-bash-4.2$ &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;exit&lt;/strong&gt;
logout
[root@localhost ~]# &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;wget http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm&lt;/strong&gt;
--2014-12-25 04:33:01--  http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm
Resolving yum.postgresql.org (yum.postgresql.org)... 174.143.35.196, 2001:4800:1501:1::196
Connecting to yum.postgresql.org (yum.postgresql.org)|174.143.35.196|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5328 (5.2K) [application/x-redhat-package-manager]
Saving to: ‘pgdg-centos94-9.4-1.noarch.rpm’

100%[==============================================&amp;gt;] 5,328       --.-K/s   in 0.002s  

2014-12-25 04:33:08 (2.46 MB/s) - ‘pgdg-centos94-9.4-1.noarch.rpm’ saved [5328/5328]

[root@localhost ~]# &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;rpm -ivh pgdg-centos94-9.4-1.noarch.rpm&lt;/strong&gt; 
Preparing...                          ################################# [100%]
Updating / installing...
   1:pgdg-centos94-9.4-1              ################################# [100%]
[root@localhost ~]# &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;systemctl stop postgresql-9.3&lt;/strong&gt;
[root@localhost ~]# &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;yum -y install postgresql94 postgresql94-devel postgresql94-contrib postgresql94-libs postgresql94-test postgresql94-server postgresql94-docs&lt;/strong&gt;
Loaded plugins: fastestmirror
base                                                                                                                                            | 3.6 kB  00:00:00     
extras                                                                                                                                          | 3.4 kB  00:00:00     
pgdg93                                                                                                                                          | 3.6 kB  00:00:00     
pgdg94                                                                                                                                          | 3.6 kB  00:00:00     
updates                                                                                                                                         | 3.4 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirror.powerhost.cl
 * extras: centos.ufms.br
 * updates: centos.ufms.br
Resolving Dependencies
--&amp;gt; Running transaction check
---&amp;gt; Package postgresql94.x86_64 0:9.4.0-1PGDG.rhel7 will be installed
---&amp;gt; Package postgresql94-contrib.x86_64 0:9.4.0-1PGDG.rhel7 will be installed
---&amp;gt; Package postgresql94-devel.x86_64 0:9.4.0-1PGDG.rhel7 will be installed
---&amp;gt; Package postgresql94-docs.x86_64 0:9.4.0-1PGDG.rhel7 will be installed
---&amp;gt; Package postgresql94-libs.x86_64 0:9.4.0-1PGDG.rhel7 will be installed
---&amp;gt; Package postgresql94-server.x86_64 0:9.4.0-1PGDG.rhel7 will be installed
---&amp;gt; Package postgresql94-test.x86_64 0:9.4.0-1PGDG.rhel7 will be installed
--&amp;gt; Finished Dependency Resolution

Dependencies Resolved

====================================================================================
 Package                                        Arch                             Version                                        Repository                        Size
====================================================================================
Installing:
 postgresql94                                   x86_64                           9.4.0-1PGDG.rhel7                              pgdg94                           1.0 M
 postgresql94-contrib                           x86_64                           9.4.0-1PGDG.rhel7                              pgdg94                           601 k
 postgresql94-devel                             x86_64                           9.4.0-1PGDG.rhel7                              pgdg94                           1.6 M
 postgresql94-docs                              x86_64                           9.4.0-1PGDG.rhel7                              pgdg94                            13 M
 postgresql94-libs                              x86_64                           9.4.0-1PGDG.rhel7                              pgdg94                           201 k
 postgresql94-server                            x86_64                           9.4.0-1PGDG.rhel7                              pgdg94                           3.8 M
 postgresql94-test                              x86_64                           9.4.0-1PGDG.rhel7                              pgdg94                           1.3 M

Transaction Summary
==========================================================================================
Install  7 Packages

Total download size: 22 M
Installed size: 72 M
Downloading packages:
(1/7): postgresql94-contrib-9.4.0-1PGDG.rhel7.x86_64.rpm                                                                                        | 601 kB  00:00:02     
(2/7): postgresql94-devel-9.4.0-1PGDG.rhel7.x86_64.rpm                                                                                          | 1.6 MB  00:00:01     
(3/7): postgresql94-9.4.0-1PGDG.rhel7.x86_64.rpm                                                                                                | 1.0 MB  00:00:17     
(4/7): postgresql94-docs-9.4.0-1PGDG.rhel7.x86_64.rpm                                                                                           |  13 MB  00:00:13     
(5/7): postgresql94-libs-9.4.0-1PGDG.rhel7.x86_64.rpm                                                                                           | 201 kB  00:00:00     
(6/7): postgresql94-server-9.4.0-1PGDG.rhel7.x86_64.rpm                                                                                         | 3.8 MB  00:00:04     
(7/7): postgresql94-test-9.4.0-1PGDG.rhel7.x86_64.rpm                                                                                           | 1.3 MB  00:00:05     
---------------------------------------------------------------------------------------
Total                                                                                                                                  933 kB/s |  22 MB  00:00:23     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : postgresql94-libs-9.4.0-1PGDG.rhel7.x86_64                                                                                                          1/7 
  Installing : postgresql94-9.4.0-1PGDG.rhel7.x86_64                                                                                                               2/7 
  Installing : postgresql94-devel-9.4.0-1PGDG.rhel7.x86_64                                                                                                         3/7 
  Installing : postgresql94-server-9.4.0-1PGDG.rhel7.x86_64                                                                                                        4/7 
  Installing : postgresql94-test-9.4.0-1PGDG.rhel7.x86_64                                                                                                          5/7 
  Installing : postgresql94-contrib-9.4.0-1PGDG.rhel7.x86_64                                                                                                       6/7 
  Installing : postgresql94-docs-9.4.0-1PGDG.rhel7.x86_64                                                                                                          7/7 
  Verifying  : postgresql94-contrib-9.4.0-1PGDG.rhel7.x86_64                                                                                                       1/7 
  Verifying  : postgresql94-test-9.4.0-1PGDG.rhel7.x86_64                                                                                                          2/7 
  Verifying  : postgresql94-9.4.0-1PGDG.rhel7.x86_64                                                                                                               3/7 
  Verifying  : postgresql94-devel-9.4.0-1PGDG.rhel7.x86_64                                                                                                         4/7 
  Verifying  : postgresql94-docs-9.4.0-1PGDG.rhel7.x86_64                                                                                                          5/7 
  Verifying  : postgresql94-server-9.4.0-1PGDG.rhel7.x86_64                                                                                                        6/7 
  Verifying  : postgresql94-libs-9.4.0-1PGDG.rhel7.x86_64                                                                                                          7/7 

Installed:
  postgresql94.x86_64 0:9.4.0-1PGDG.rhel7              postgresql94-contrib.x86_64 0:9.4.0-1PGDG.rhel7         postgresql94-devel.x86_64 0:9.4.0-1PGDG.rhel7         
  postgresql94-docs.x86_64 0:9.4.0-1PGDG.rhel7         postgresql94-libs.x86_64 0:9.4.0-1PGDG.rhel7            postgresql94-server.x86_64 0:9.4.0-1PGDG.rhel7        
  postgresql94-test.x86_64 0:9.4.0-1PGDG.rhel7        

Complete!
[root@localhost ~]# &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;/usr/pgsql-9.4/bin/postgresql94-setup initdb&lt;/strong&gt;
Initializing database ... OK

[root@localhost ~]# &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;systemctl enable postgresql-9.4&lt;/strong&gt;
ln -s &#39;/usr/lib/systemd/system/postgresql-9.4.service&#39; &#39;/etc/systemd/system/multi-user.target.wants/postgresql-9.4.service&#39;
[root@localhost ~]# &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;systemctl disable postgresql-9.3&lt;/strong&gt;
rm &#39;/etc/systemd/system/multi-user.target.wants/postgresql-9.3.service&#39;
[root@localhost ~]# &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;systemctl start postgresql-9.4&lt;/strong&gt;
[root@localhost ~]# &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;su - postgres&lt;/strong&gt;
Last login: Thu Dec 25 04:31:31 EST 2014 on pts/0
-bash-4.2$ &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;psql&lt;/strong&gt;
psql (9.4.0)
Type &quot;help&quot; for help.

postgres=# &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;\q&lt;/strong&gt;
-bash-4.2$ &lt;strong style=&quot;border: 0px; font-size: 13.9200000762939px; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;psql &amp;lt; backup.sql&lt;/strong&gt; 
SET
SET
SET
ERROR:  role &quot;postgres&quot; already exists
ALTER ROLE
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database &quot;postgres&quot; as user &quot;postgres&quot;.
SET
SET
SET
SET
SET
SET
SET
COMMENT
CREATE EXTENSION
COMMENT
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database &quot;template1&quot; as user &quot;postgres&quot;.
SET
SET
SET
SET
SET
SET
SET
COMMENT
CREATE EXTENSION
COMMENT
REVOKE
REVOKE
GRANT
GRANT
-bash-4.2$&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/3797489419562651376/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2015/02/upgrade-de-postgresql-93-para-94-em.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/3797489419562651376'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/3797489419562651376'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2015/02/upgrade-de-postgresql-93-para-94-em.html' title='Upgrade de PostgreSQL 9.3 para 9.4 (em CentOS 7)'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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-393809595399109651.post-6483828711825687924</id><published>2015-02-10T10:42:00.002-08:00</published><updated>2015-09-24T22:10:02.656-07:00</updated><title type='text'>Como instalar PostgreSQL 9.4 no CentOS e sistemas derivados</title><content type='html'>&lt;div style=&quot;background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 25.2000007629395px; margin-bottom: 10px;&quot;&gt;
Para instalar o programa no CentOS 6.4, 6.5 e 7, e ainda poder receber automaticamente as futuras atualizações dele, você deve fazer o seguinte:&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 25.2000007629395px; margin-bottom: 10px;&quot;&gt;
Passo 1. Abra um terminal;&lt;br /&gt;Passo 2. Confira se o seu sistema é de 32 bits ou 64 bits, para isso, use o seguinte comando no terminal:&lt;/div&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.14902); color: #333333; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 13px; line-height: 20px; margin-bottom: 10px; padding: 9.5px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;code style=&quot;background-color: transparent; border-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 12px; padding: 0px;&quot;&gt;uname -m&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 25.2000007629395px; margin-bottom: 10px;&quot;&gt;
Passo 3. Se seu sistema é um CentOS 6.x de 32 bits, use o comando abaixo para adicionar o repositório do PostgreSQL 9.4:&lt;/div&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.14902); color: #333333; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 13px; line-height: 20px; margin-bottom: 10px; padding: 9.5px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;code style=&quot;background-color: transparent; border-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 12px; padding: 0px;&quot;&gt;rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-i386/pgdg-centos94-9.4-1.noarch.rpm&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 25.2000007629395px; margin-bottom: 10px;&quot;&gt;
Passo 4. Se seu sistema é um CentOS 6.x de 64 bits, use o comando abaixo para adicionar o repositório do PostgreSQL 9.4:&lt;/div&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.14902); color: #333333; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 13px; line-height: 20px; margin-bottom: 10px; padding: 9.5px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;code style=&quot;background-color: transparent; border-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 12px; padding: 0px;&quot;&gt;rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 25.2000007629395px; margin-bottom: 10px;&quot;&gt;
Passo 5. Se seu sistema é um CentOS 7 de 64 bits, use o comando abaixo para adicionar o repositório do PostgreSQL 9.4:&lt;/div&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.14902); color: #333333; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 13px; line-height: 20px; margin-bottom: 10px; padding: 9.5px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;code style=&quot;background-color: transparent; border-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 12px; padding: 0px;&quot;&gt;rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 25.2000007629395px; margin-bottom: 10px;&quot;&gt;
Passo 6. Atualize o gerenciador de pacotes com o comando:&lt;/div&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.14902); color: #333333; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 13px; line-height: 20px; margin-bottom: 10px; padding: 9.5px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;code style=&quot;background-color: transparent; border-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 12px; padding: 0px;&quot;&gt;yum update&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 25.2000007629395px; margin-bottom: 10px;&quot;&gt;
Passo 7. Agora use o comando abaixo para instalar o programa;&lt;/div&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.14902); color: #333333; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 13px; line-height: 20px; margin-bottom: 10px; padding: 9.5px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;code style=&quot;background-color: transparent; border-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 12px; padding: 0px;&quot;&gt;yum install postgresql94-server postgresql94-contrib&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 25.2000007629395px; margin-bottom: 10px;&quot;&gt;
Pronto! Agora, se o banco não for inicializado na instalação, reinicie o sistema e quando quiser, verifique a versão do PostgreSQL usando o seguinte comando em um terminal:&lt;/div&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.14902); color: #333333; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 13px; line-height: 20px; margin-bottom: 10px; padding: 9.5px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;code style=&quot;background-color: transparent; border-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 12px; padding: 0px;&quot;&gt;psql --version&lt;/code&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://solucoesdba.blogspot.com/feeds/6483828711825687924/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://solucoesdba.blogspot.com/2015/02/como-instalar-postgresql-94-no-centos-e.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/6483828711825687924'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393809595399109651/posts/default/6483828711825687924'/><link rel='alternate' type='text/html' href='http://solucoesdba.blogspot.com/2015/02/como-instalar-postgresql-94-no-centos-e.html' title='Como instalar PostgreSQL 9.4 no CentOS e sistemas derivados'/><author><name>solucoesdba</name><uri>http://www.blogger.com/profile/00294555759203008716</uri><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></feed>