<?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-4017673185899003667</id><updated>2026-01-12T14:34:26.532-08:00</updated><title type='text'>Linux x PostgreSQL</title><subtitle type='html'>Neste blog, vou postar as minhas experiências sobre Linux e o uso de um dos melhores banco de dados PostgreSQL</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-6680563641684940872</id><published>2015-10-26T06:40:00.001-07:00</published><updated>2015-10-26T06:40:19.410-07:00</updated><title type='text'>Insert com a recuperação do ID</title><content type='html'>Buenas pessoal, já faz muito tempo que não posto nada, não por não ter o que postar, mas sim, por estar fazendo a graduação na área e o tempo faltando aos montes.&lt;br /&gt;
&lt;br /&gt;
Hoje resolvi postar algo simples, mas que dá muito trabalho aos programadores em iniciantes quando sem fala em &quot;inserts&quot; em tabelas relacionas.&lt;br /&gt;
&lt;br /&gt;
Um exemplo do que estou falando, é a simples ação de incluir o cabeçalho de um pedido e obter o ID do mesmo para incluir seus itens. Há programadores que utilizam uma tabela para estas duas ações, mas no meu caso, sempre uso duas, das quais chamo de mestre x detalhe.&lt;br /&gt;
&lt;br /&gt;
Para dar um exemplo, é preciso criar um tabela simples. Segue o comando:&lt;br /&gt;
&lt;br /&gt;
Create table &quot;Pedido&quot;(ID_Pedido serial primary key, Total Numeric);&lt;br /&gt;
&lt;br /&gt;
Quando todo o processo é feito via banco de dados, ou seja, através de funções, podemos utilizar pelo menos duas opções para retornar este ID:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1º Através de comando &quot;nextval&quot;&lt;br /&gt;
&lt;br /&gt;
create or replace function inserir_pedido1() returns integer as&lt;br /&gt;$$&lt;br /&gt;declare&lt;br /&gt;
&amp;nbsp; --Cria-se uma variável para receber o valor &quot;nextval&quot; &lt;br /&gt;&amp;nbsp; xID_Pedido Integer default 0;&lt;br /&gt;begin &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --Recuperando o ID via comando &quot;nextval&quot;&lt;br /&gt;
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xID_Pedido = nextval(&#39;&quot;Pedido_id_pedido_seq&quot;&#39;); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --Insert utilizando a variável para gravar o ID na tabela mestre e retornar a&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; --função para depois utilizar na inclusão dos itens.&lt;br /&gt;
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Insert Into &quot;Pedido&quot; (ID_Pedido, Total) Values( XID_Pedido, 1.5);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --Retornando o valor do ID&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return XID_Pedido;&lt;br /&gt;end;&lt;br /&gt;$$ &lt;br /&gt;language plpgsql;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Chamada da função que inclui o mestre do pedido&lt;br /&gt;Select inserir_pedido1();&lt;br /&gt;&lt;br /&gt;
&lt;br /&gt;
2º Através do comando &quot;returning&quot;&lt;br /&gt;
&lt;br /&gt;
create or replace function inserir_pedido2() returns integer as&lt;br /&gt;$$&lt;br /&gt;declare &lt;br /&gt;&amp;nbsp; --Cria-se uma variável para receber o valor &quot;into&quot;&lt;br /&gt;&amp;nbsp; XID Integer;&lt;br /&gt;begin&lt;br /&gt;&amp;nbsp;--Recuperando o ID via comando &quot;returning&quot;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Insert Into &quot;Pedido&quot; (Total) Values(1.5) returning ID_Pedido into XID;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;return XID;&lt;br /&gt;&lt;br /&gt;end; &lt;br /&gt;$$ &lt;br /&gt;language plpgsql;&lt;br /&gt;&lt;br /&gt;--Chamada da função que inclui o mestre do pedido&lt;br /&gt;Select inserir_pedido2();&lt;br /&gt;
&lt;br /&gt;
A segunda opção, é a mais ideal a ser usada, levando em conta, que ao mesmo tempo que se envia os dados via comando &quot;insert&quot;, se recebe o valor &quot;id&quot; gravado pela &quot;sequence&quot; do banco, sem a necessidade de executar dois comandos, ou seja, abrir duas sessões em vez de uma.&lt;br /&gt;
&lt;br /&gt;
O comando &quot;returning&quot; retorna o valor gerado pela &quot;sequence&quot; e gravado na tabela no campo primário.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/6680563641684940872/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2015/10/insert-com-recuperacao-do-id.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/6680563641684940872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/6680563641684940872'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2015/10/insert-com-recuperacao-do-id.html' title='Insert com a recuperação do ID'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-654661920173860510</id><published>2012-05-24T10:55:00.000-07:00</published><updated>2012-05-24T10:55:43.868-07:00</updated><title type='text'>PostrgreSQL Uso do &quot;Copy To&quot;</title><content type='html'>&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Introdução&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Pessoal, h&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;oje, eu gostaria de mostrar um exemplo simples, de como usar o&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;comando &lt;b&gt;&quot;Copy To&quot;.&lt;/b&gt;&amp;nbsp;&amp;nbsp;Este comando, faz a carga de uma tabela&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp;para dentro de um arquivo.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Sintaxe do comando&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;COPY tablename [ ( column [, ...] ) ]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; TO { &#39;filename&#39; | STDOUT }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; [ [ WITH ]&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [ BINARY ]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [ OIDS ]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [ DELIMITER [ AS ] &#39;delimiter&#39; ]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [ NULL [ AS ] &#39;null string&#39; ]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [ CSV [ HEADER ]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [ QUOTE [ AS ] &#39;quote&#39; ]&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [ ESCAPE [ AS ] &#39;escape&#39; ]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [ FORCE QUOTE column [, ...] ]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Obs: &lt;/b&gt;Maiores explicações sobre cada parâmetro, acesse a documentação em português&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;do PostgreSQL em&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://pgdocptbr.sourceforge.net/pg80/sql-copy.html&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;http://pgdocptbr.sourceforge.net/pg80/sql-copy.html&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Mãos&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp;ao trabalho. &amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Vamos criar uma função, onde o conteúdo de uma de nossas tabelas, neste caso, a de &quot;clientes&quot; serão gravados dentro de um arquivo.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;CREATE OR REPLACE FUNCTION &quot;CopyTo&quot;(Caminho Varchar)&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;b style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;&amp;nbsp; RETURNS boolean AS&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;$BODY$&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Declare&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; /*&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; Duas variáveis,&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;A primeira, &quot;Retorno&quot; do tipo &quot;Record&quot; utilizada para guardar registros. Ela&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; assume a strutura&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; da tabela ou tabelas informadas no SQL.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; A segunda, &quot;Sql&quot; do tipo &quot;Varchar&quot; utilizada para guardar os comandos SQL, que após&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; serão executados por &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; outro comando &quot;Execute&quot;.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; Retorno Record;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; Sql &amp;nbsp; &amp;nbsp; Varchar default &#39;&#39;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Begin&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; /*&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; Aqui, é criado uma tabela tempória para receber dados criteriados,&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;de outra tabela de nosso banco de&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;dados.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; Sql = &#39;Create Temp Table &quot;RemessaTemp&quot;(&quot;CodigoCliente&quot; integer) On Commit Drop;&#39;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;b&gt; Execute Sql;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; /*&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; Neste ponto, o SQL, envia para dentro da variável &quot;Retorno&quot; os registros&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; encontrados e criteriados na claúsula &quot;Where&quot;.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;&amp;nbsp; For Retorno in&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Select &quot;CodigoCliente&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; From &amp;nbsp; &quot;Cliente&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Where &amp;nbsp;&quot;DataNascimentoCliente&quot; between &#39;2012-01-01&#39; and &#39;2012-03-01&#39;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;&amp;nbsp; Loop&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; /*&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; Após, entramos em um loop, dando um &quot;Insert&quot; dos dados para dentro da tabela&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;temporária.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; XSql = &#39;Insert Into &quot;Temp&quot; (&quot;CodigoCliente&quot;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; Values (&#39;||Quote_Literal(XRetorno.&quot;CodigoCliente&quot;)||&#39;);&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; Execute XSql;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;&amp;nbsp; End Loop;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; /*&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; Agora vamos para o final, criar o arquivo com os dados contidos na tabela&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; temporária.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&amp;nbsp; */&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; XSql = &#39;Copy &quot;Temp&quot; To &#39;||Quote_Literal($1);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;&amp;nbsp; Execute XSql;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;&amp;nbsp; Return true;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;end;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;$BODY$&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;&amp;nbsp; LANGUAGE &#39;plpgsql&#39; VOLATILE;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Para executar a função, onde que cria o arquivo com os dados de uma tabela, faça:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Select &quot;CopyTo&quot;(&#39;Diretório para gravação\Nome do arquivo.csv&#39;);&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Considerações: &lt;/b&gt;No próximo artigo, eu irei demonstrar o inverso deste comando, utilizando o &lt;b&gt;&quot;Copy From&quot;, &lt;/b&gt;onde irei ler o contéudo de um arquivo e gravar dentro de uma tabela. Uma detalhe importante, mas não exatamente uma regra, é que, o arquivo lido, deverá ter a mesma estrutura de registros igual a sua tabela. No exemplo acima, eu uso um único campo, com isto o arquivo terá uma única coluna. Para demais colunas, usar os caracteres determinados pela sintaxe do comando.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/654661920173860510/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2012/05/postrgresql-uso-do-copy-to.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/654661920173860510'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/654661920173860510'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2012/05/postrgresql-uso-do-copy-to.html' title='PostrgreSQL Uso do &quot;Copy To&quot;'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-6020222229338902273</id><published>2012-04-26T16:59:00.001-07:00</published><updated>2012-04-26T17:26:50.808-07:00</updated><title type='text'>Uso dos comandos &quot;Create Types&quot; e &quot;Execute&quot; em funções PostgreSQL</title><content type='html'>&lt;div style=&quot;color: black; font-family: Arial,Helvetica,sans-serif;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: white; font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp; Neste artigo, eu tento demostrar o uso que eu faço dos comandos &quot;Create Type&quot; e do &quot;Execute&quot;.&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;O &quot;Create Type&quot;&lt;/b&gt;, permite criar um novo tipo de dado. No meu caso, uso ele para as saídas de dados(lista campos e seus conteúdos pertencentes a uma tabela pesquisada) das funções que faço no banco. &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: Arial,Helvetica,sans-serif;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;O &quot;Execute&quot;, &lt;/b&gt;é um comando utilizado em funções &quot;plpgsql&quot;, para executar sql, contidos dentro de uma variavel do tipo texto. Este procedimento, é interessante, para que possámos unir strings mais complexas, fazendo delas, um sql mais enxuto, e dando a possíbilidade de &lt;b&gt;NÃO &lt;/b&gt;usar comandos como: &quot;&lt;b&gt;Case When&lt;/b&gt;&quot; ou &quot;&lt;b&gt;If then&quot;&lt;/b&gt;, que em muitas vezes, não deixa que o banco uses seus índices, necessários para agilizar uma determinada consulta. &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: Arial,Helvetica,sans-serif;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;u&gt;Para criar um type faça:&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Create type &quot;ListaPessoas_Type&quot; as&lt;br /&gt;&amp;nbsp;(&quot;CodigoPessoa&quot;&amp;nbsp;&amp;nbsp; Integer,&lt;br /&gt;&amp;nbsp; &quot;NomePessoa&quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Varchar(100)) ;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;A função a seguir, lista dois campos de uma tabela, chamada &quot;Pessoas&quot;, onde a informações listadas, poderão serem &quot;Clientes&quot; ou &quot;Fornecedores&quot;.&amp;nbsp; Vejam, que os &lt;b&gt;types&lt;/b&gt; criado, cuja o nome ficou &lt;b&gt;&quot;ListaPessoas_Type&quot;&lt;/b&gt;, é atrelado a função logo nas primeiras linhas, onde que representa a saída dos dados.&lt;br /&gt;&lt;br /&gt;A proposta aqui, é mostrar o uso do &lt;b&gt;create type&lt;/b&gt; e do&lt;b&gt; execute&lt;/b&gt;. Sei, que consultas como estas, poderiam serem feitas de uma outra forma, de tamanho menor e numa função do tipo &quot;sql&quot; e não &quot;plpgsql&quot;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: white;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: white;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: white;&quot;&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif; font-size: small;&quot;&gt;&lt;u&gt;Para criar a função faça:&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: white;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Create or replace function &quot;ListaPessoas&quot;(varchar(15))&lt;br /&gt;Returns setof &quot;ListaPessoas_Type&quot; As&lt;br /&gt;$$&lt;br /&gt;declare&lt;br /&gt;&amp;nbsp;&amp;nbsp; XSQL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text;&lt;br /&gt;&amp;nbsp;&amp;nbsp; XRetorno Record;&amp;nbsp; &lt;br /&gt;begin&lt;br /&gt;&amp;nbsp; /*Montagem do sql em uma variável text*/&lt;br /&gt;&amp;nbsp; if $1 = &#39;Clientes&#39; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XSQL = &#39;Select &quot;CodigoPessoa&quot;,&quot;NomePessoa&quot;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; From &amp;nbsp; &quot;Pessoas&quot;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Where&amp;nbsp; &quot;TipoCliente&quot; = &#39;&#39;Clientes&#39;&#39;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Order by &quot;NomePessoa&quot;&#39;;&lt;br /&gt;&amp;nbsp; else&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; XSQL = &#39;Select &quot;CodigoPessoa&quot;,&quot;NomePessoa&quot;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; From &amp;nbsp; &quot;Pessoas&quot;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Where&amp;nbsp; &quot;TipoCliente&quot; = &#39;&#39;Clientes&#39;&#39;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Order by &quot;NomePessoa&quot;&#39;;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; end if;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; /*Executa o conteúdo da variável XSQL*/&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;div style=&quot;color: white;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;&amp;nbsp; For XRetorno in&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Execute XSQL&lt;br /&gt;&amp;nbsp; loop&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return Next XRetorno;&lt;br /&gt;&amp;nbsp; end loop;&lt;br /&gt;end;&lt;br /&gt;$$ Language plpgsql;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: white;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: white;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: white;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;Linha de comando para fazer a chamada a função&lt;/span&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: white;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/u&gt; &lt;/b&gt;&lt;br /&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Select * From &quot;ListaPessoas&quot;(&#39;Clientes&#39;);&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: white;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: white;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: white; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif; font-size: small;&quot;&gt;&lt;b&gt;Observações: &lt;/b&gt;Em testes passados, consegui comprovar, o ganho em tempo de retorno de dados pesquisado, quando usamos quando criamos os tipos de campos para o retorno de uma função.&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/6020222229338902273/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2012/04/uso-dos-comandos-create-types-e-execute.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/6020222229338902273'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/6020222229338902273'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2012/04/uso-dos-comandos-create-types-e-execute.html' title='Uso dos comandos &quot;Create Types&quot; e &quot;Execute&quot; em funções PostgreSQL'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-4575735647094928242</id><published>2012-04-20T06:32:00.001-07:00</published><updated>2012-04-20T06:33:31.201-07:00</updated><title type='text'>Backup banco PostgreSQL pelo Linux</title><content type='html'>&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;Gente, novamente venho a contribuir um pouquinho, com algum pouco conhecimento que tenho sobre &lt;b&gt;Linux e PostgreSQL. &lt;/b&gt;Neste &lt;b&gt;script(Linux), &lt;/b&gt;do qual dou o nome de &lt;b&gt;&quot;backup.postgres.sh&quot;, &lt;/b&gt;faço o backup do banco pg, levando em conta:&lt;br /&gt;1º A existência da pasta para receber o arquivo(&lt;b&gt;mkdir -p&lt;/b&gt;);&lt;br /&gt;2º Uma analise, e ao mesmo tempo, a exclusão dos arquivos a mais de 3 dias(&lt;b&gt;find&lt;/b&gt;);&lt;br /&gt;3º O backup propriamente dito(&lt;b&gt;pg_dump);&lt;/b&gt;&lt;br /&gt;4º&lt;b&gt;&amp;nbsp;&lt;/b&gt;Por final, o vacuum para limpar e organizar e com isto agilizar o banco para o dia seguinte(&lt;b&gt;vacuum&lt;/b&gt;).&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#Scritp responsável pela cópia do banco de dados &lt;b&gt;PostgreSQL&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#Autor: Marcos Andre G.A&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#Data1: 02/04/2012&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#1º Mensagem que mostra na tela a data e hora de início do backup.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;DATA=`date +%Y%m%d`&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;HORA=`date +%H%M`&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;echo &quot;+++ .&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;echo &quot;+++ Data/Hora do inicio da copia. &quot;$DATA $HORA&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;echo &quot;+++ .&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#2º Criando, caso não exista,&amp;nbsp;&quot;&lt;b&gt;mkdir -p&quot;&amp;nbsp;&lt;/b&gt;a pasta para receber o banco.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;mkdir -p /opt/backups/base_de_dados/&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#3º Procedimento de limpeza dos backups com data a mais de 3 dias.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;echo &quot;+++ Executando limpeza das copias dos bancos de dados a mais de 3 dias&quot;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;find&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;/opt/backups/base_de_dados/&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;-name &#39;Trabin*&#39; -ctime +3 -exec rm -fv {} \;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#4º Procedimento que gera cópia do bando de dados.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;echo &quot;+++ Gerando copia do banco. Aguarde...&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;pg_dump -Fc -Z9 -U postgres -h localhost -f&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;/opt/backups/base_de_dados/&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;/Nome_do_Banco_$DATA$HORA.bkp &amp;nbsp;&quot;Nome_do_Banco&quot;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;echo &quot;+++ Nome_do_Banco copiado!&quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#5º Neste ponto, gero um vacuum. Abaixo, a lista dos parâmetros possíveis.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;echo &quot; &quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;echo &quot;+++ Gerando o vacuum do banco, Aguarde...&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#-a : passa em todos bancos de dados;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#-d base : para escolher o banco de dados;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#-f : vacuum full;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#-z - vacuum analyze;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#-v : verbose;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#-h : servidor remoto postgres;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#-U : login do usuarioo do banco.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;vacuumdb -d &quot;Nome_do_Banco&quot; &amp;nbsp; &amp;nbsp;-U postgres -q -z&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;#echo &quot;+++ Vacuum - TrabinBase ok&quot;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/4575735647094928242/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2012/04/gente-novamente-venho-contribuir-um.html#comment-form' title='1 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/4575735647094928242'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/4575735647094928242'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2012/04/gente-novamente-venho-contribuir-um.html' title='Backup banco PostgreSQL pelo Linux'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-9057970261969067681</id><published>2012-04-12T07:15:00.000-07:00</published><updated>2012-04-13T05:09:45.924-07:00</updated><title type='text'>Campos associados em uma consulta SQL</title><content type='html'>&lt;br /&gt;
Buenas pessoal, hoje rapidamente lembrei de algo que muitas vezes é comum mas não é de uso de todos. &lt;b&gt;Fazer&lt;/b&gt; SQL com campos de tabelas associadas. Ou a grosso modo, pegar o valor de um campo de outra tabela e mostrar no sql que estamos construindo. No PG, eu tenho sempre uma função que ao passar o ID que esta gravado na tabela principal a tabela secundária, me retorna o valor do campo que desejo. Isto, daria para fazer sem a necessidade de uma função, mas é mais organizado e tu pode aproveitar em outras partes do sistema.&lt;br /&gt;
&lt;br /&gt;
Bom, esta função, recebe o ID da Cidade que esta na tabela de clientes e retorna o nome da cidade&lt;br /&gt;
&lt;br /&gt;
CREATE OR REPLACE FUNCTION &quot;RetornaCidadeNome&quot;(Integer)&lt;br /&gt;
&amp;nbsp; RETURNS Varchar AS&lt;br /&gt;
$BODY$&lt;br /&gt;
&amp;nbsp; &amp;nbsp;Select Cast(&quot;NomeCidade&quot; as Varchar)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;From &amp;nbsp; &lt;b&gt;&quot;Cliente&quot;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;Where &amp;nbsp;&quot;&lt;b&gt;CodigoIDCliente&lt;/b&gt;&quot;=$1&lt;br /&gt;
$BODY$&lt;br /&gt;
&amp;nbsp; LANGUAGE &#39;sql&#39;;&lt;br /&gt;
&lt;br /&gt;
Este é o SQL que mostra os dados dos clientes mais o nome da cidade, do cliente 1 ao 1000&lt;br /&gt;
&lt;br /&gt;
Select &quot;CodigoCliente&quot;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;NomeCliente,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;RetornaCidadeNome&quot;(&quot;CodigoIDCidadeCliente&quot;) as &quot;XNomeCidade&quot;&lt;br /&gt;
From &quot;Cidade&quot;&lt;br /&gt;
Where &quot;CodigoCliente&quot; between 1 and 1000;&lt;br /&gt;
&lt;br /&gt;
Detalhes: Aspas duplas, garante que no postgresql o nome da função fique como foi digitada.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
Obs: Pessoal, fiz algumas alterações pontuações, das quais, estão em negrito.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/9057970261969067681/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2012/04/campos-associados-em-uma-consulta-sql.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/9057970261969067681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/9057970261969067681'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2012/04/campos-associados-em-uma-consulta-sql.html' title='Campos associados em uma consulta SQL'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-6209816304109457861</id><published>2012-03-30T13:03:00.001-07:00</published><updated>2012-03-30T13:03:37.617-07:00</updated><title type='text'>Cálculo do Módulo11 para o Nosso Número</title><content type='html'>&lt;br /&gt;
No exemplo anterior postado, eu mostro como fazer um cálculo do dígito verificador módulo10 do banco do brasil, e neste, mostro como é feito o cálculo usando o módulo11. Essas duas funções, referente aos chamados DV(Dígito Verificador), podem serem executadas sem nenhuma alteração, pois, elas não fazem referência as tabelas do banco de dados, são funções das quais chamo de &quot;Genéricas&quot;.&lt;br /&gt;
&lt;br /&gt;
CREATE OR REPLACE FUNCTION &quot;TS_ParcelaBloquetoBancoBrasilModulo11&quot;(xdocumento character varying)&lt;br /&gt;
&amp;nbsp; RETURNS character varying AS&lt;br /&gt;
$BODY$&lt;br /&gt;
declare&lt;br /&gt;
&amp;nbsp; XNumero &amp;nbsp; &amp;nbsp; Varchar;&lt;br /&gt;
&amp;nbsp; XNumeroOrg &amp;nbsp;Varchar;&lt;br /&gt;
&amp;nbsp; XCont &amp;nbsp; &amp;nbsp; &amp;nbsp; Integer;&lt;br /&gt;
&amp;nbsp; XParcial &amp;nbsp; &amp;nbsp;Integer;&lt;br /&gt;
&amp;nbsp; XDivisorM11 Integer;&lt;br /&gt;
&amp;nbsp; XResto &amp;nbsp; &amp;nbsp; &amp;nbsp;Integer;&lt;br /&gt;
&amp;nbsp; XDigVerM11 &amp;nbsp;Integer;&lt;br /&gt;
&amp;nbsp; XMultiplo &amp;nbsp; Integer;&lt;br /&gt;
begin&lt;br /&gt;
&amp;nbsp; /*&lt;br /&gt;
&amp;nbsp; &amp;nbsp;Função responsável por calcular o DV módulo 11&lt;br /&gt;
&amp;nbsp; &amp;nbsp;Esta informação vai impressa no bloqueto&lt;br /&gt;
&amp;nbsp; */&lt;br /&gt;
&amp;nbsp; --Pegando somente os números do documentos&lt;br /&gt;
&amp;nbsp; XNumeroOrg = regexp_replace(XDocumento, &#39;[^[:digit:]]&#39;, &#39;&#39;, &#39;g&#39;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; /*&lt;br /&gt;
&amp;nbsp; *** Calculando Módulo &quot;11&quot; ***&lt;br /&gt;
&amp;nbsp; */&lt;br /&gt;
&amp;nbsp; XDivisorM11 = 2;&lt;br /&gt;
&amp;nbsp; XParcial &amp;nbsp; &amp;nbsp;= 0;&lt;br /&gt;
&amp;nbsp; XNumero &amp;nbsp; &amp;nbsp; = trim(XNumeroOrg);&lt;br /&gt;
&amp;nbsp; XCont &amp;nbsp; &amp;nbsp; &amp;nbsp; = length(XNumero);&lt;br /&gt;
&amp;nbsp; loop&lt;br /&gt;
&amp;nbsp; &amp;nbsp; --Pegando número a número e multiplicando por 2 a 9 e acumulando o resultado linha a linha&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if XDivisorM11 &amp;gt; 9 then&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;XDivisorM11 = 2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; end if;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; XParcial &amp;nbsp; &amp;nbsp;= XParcial &amp;nbsp; &amp;nbsp;+ Cast(SubStr(trim(XNumero),XCont,1) as Integer) * XDivisorM11;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; XDivisorM11 = XDivisorM11 + 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; XCont &amp;nbsp; &amp;nbsp; &amp;nbsp; = XCont - 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if XCont = 0 then&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Exit;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; end if;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; end loop;&lt;br /&gt;
&amp;nbsp; /*&lt;br /&gt;
&amp;nbsp; Tratando o resultado da multiplicação&lt;br /&gt;
&amp;nbsp; */&lt;br /&gt;
&amp;nbsp; XResto &amp;nbsp; &amp;nbsp; = Cast(((XParcial-(trunc(Cast(XParcial as Numeric(15,2))/11))*11)) as Integer);&lt;br /&gt;
&amp;nbsp; XDigVerM11 = 11 - XResto;&lt;br /&gt;
&amp;nbsp; if XDigVerM11 = 0 or XDigVerM11 = 10 or XDigVerM11 = 11 then&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;XDigVerM11 = 1;&lt;br /&gt;
&amp;nbsp; end if;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Return XDigVerM11;&lt;br /&gt;
end;&lt;br /&gt;
$BODY$&lt;br /&gt;
&amp;nbsp; LANGUAGE &#39;plpgsql&#39; VOLATILE;&lt;br /&gt;
ALTER FUNCTION &quot;TS_ParcelaBloquetoBancoBrasilModulo11&quot;(character varying) OWNER TO postgres;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
*** Para executar esta função digite: ***&lt;br /&gt;
&lt;b&gt;Select&amp;nbsp;&quot;TS_ParcelaBloquetoBancoBrasilModulo11&quot;(&#39;12345678&#39;)&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/6209816304109457861/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2012/03/calculo-do-modulo11-para-o-nosso-numero.html#comment-form' title='4 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/6209816304109457861'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/6209816304109457861'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2012/03/calculo-do-modulo11-para-o-nosso-numero.html' title='Cálculo do Módulo11 para o Nosso Número'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-5819462455398401693</id><published>2012-03-29T07:26:00.000-07:00</published><updated>2012-03-30T13:05:22.189-07:00</updated><title type='text'>Cálculo do Módulo10 para o Nosso Número</title><content type='html'>&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Neste exemplo, criei em plpgsql, uma função para o cálculo do módulo10, para usar na geração do &quot;Nosso Número&quot; para a remessa e bloquetos do banco do brasil.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;CREATE OR REPLACE FUNCTION &quot;TS_CalculaModulo10BancoBrasili&quot;(xdocumento character varying)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; RETURNS character varying AS&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$BODY$&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;declare&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XNumero &amp;nbsp; &amp;nbsp; Varchar;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XNumeroOrg &amp;nbsp;Varchar;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XCont &amp;nbsp; &amp;nbsp; &amp;nbsp; Integer;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XParcial &amp;nbsp; &amp;nbsp;Integer;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XParcialPosterior Integer;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XDivisorM10 Integer;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XResto &amp;nbsp; &amp;nbsp; &amp;nbsp;Integer;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XDigVerM10 &amp;nbsp;Varchar(1);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XMultiplo &amp;nbsp; Integer;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XTotalM10 &amp;nbsp; Integer;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;begin&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; /*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;Função responsável por calcular o módulo 10&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;para os campos da linha digitável cobrança banco do brasil&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; */&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; --Pegando somente os números do documentos&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XNumeroOrg = regexp_replace(XDocumento, &#39;[^[:digit:]]&#39;, &#39;&#39;, &#39;g&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; /*&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; *** Calculando Módulo &quot;10&quot; ***&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; */&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XDivisorM10 = 2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XParcial &amp;nbsp; &amp;nbsp;= 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XNumero &amp;nbsp; &amp;nbsp; = trim(XNumeroOrg);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; XCont &amp;nbsp; &amp;nbsp; &amp;nbsp; = length(XNumero);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; loop&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; XTotalM10 = Cast(SubStr(trim(XNumero),XCont,1) as Integer) * XDivisorM10;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; if XTotalM10 &amp;lt; 10 then&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;XParcial &amp;nbsp; &amp;nbsp;= XParcial &amp;nbsp; &amp;nbsp;+ XTotalM10;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; else&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;XParcial &amp;nbsp; &amp;nbsp;= XParcial &amp;nbsp; &amp;nbsp;+ (Cast(SubStr(XTotalM10,1,1) as Integer) + Cast(SubStr(XTotalM10,2,1) as Integer));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; end if;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; XCont &amp;nbsp; &amp;nbsp; &amp;nbsp; = XCont - 1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; if XCont = 0 then&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Exit;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; end if;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; --Pegando número a número e multiplicando por 2 e 1 e acumulando o resultado linha a linha&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; if XDivisorM10 = 1 then&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;XDivisorM10 = 2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; else&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;XDivisorM10 = 1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; end if;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; end loop;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; /*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; Após achar o resto da divisão, encontrar o maior&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; valor da soma e fazer a subtração&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; */&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; if Length(XParcial) &amp;lt;= 2 then&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;XParcialPosterior = (SubStr(Cast(XParcial+10 as Varchar),1,1)||&#39;0&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; elsif Length(XParcial) = 3 then &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;XParcialPosterior = (SubStr(Cast(XParcial+10 as Varchar),1,2)||&#39;0&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; elsif Length(XParcial) = 4 then &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;XParcialPosterior = (SubStr(Cast(XParcial+10 as Varchar),1,2)||&#39;0&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; end if; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; if (XParcialPosterior-XParcial) = 10 &amp;nbsp;then -- Se maior que 9 desmembrar o número e soma-los Resto = 18 fazer 1 + 8 = 9&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Return (0);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; else &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Return (XParcialPosterior-XParcial);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; end if;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;end;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$BODY$&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; LANGUAGE &#39;plpgsql&#39; VOLATILE;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
*** Para executar esta função digite: ***&lt;br /&gt;
&lt;b&gt;Select&amp;nbsp;&quot;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;TS_CalculaModulo10BancoBrasili&lt;/span&gt;&quot;(&#39;12345678&#39;)&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;No próximo post, mostrarei a função que cálcula o DV, usando o módulo11.&amp;nbsp;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/5819462455398401693/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2012/03/calculo-do-modulo10-para-o-nosso-numero.html#comment-form' title='1 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/5819462455398401693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/5819462455398401693'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2012/03/calculo-do-modulo10-para-o-nosso-numero.html' title='Cálculo do Módulo10 para o Nosso Número'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-3850580649882424500</id><published>2012-01-13T03:18:00.000-08:00</published><updated>2012-01-13T03:18:29.272-08:00</updated><title type='text'>Substituir String por outra String</title><content type='html'>&lt;br /&gt;
Algumas vezes precisamos limpar um conjunto de caracteres para ficarmos somente com o que interessa, ou, trocar um caracter por outro correspondente. Um exemplo disto, é o CNPJ ou CPF, onde, dependendo de onde se pega a informação, vem com os caracteres &#39;/&#39;(barra), &#39;.&#39;(ponto) e ou &#39;-&#39;(hífen).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Exemplo1: &lt;/b&gt;Trocar na ordem os pontos e hifens por null&lt;br /&gt;
Select translate(&#39;999.999.999-72&#39;, &#39;.-&#39;,&#39;&#39;); Aqui eu mando pegar o número e tirar os pontos e hifens caso tenha.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;b&gt;Exemplo2:&amp;nbsp;&lt;/b&gt;Trocar na ordem os pontos por sinal de + e hifens por *&lt;br /&gt;
&lt;br /&gt;
Select translate(&#39;999.999.999-72&#39;, &#39;.-&#39;,&#39;+*&#39;); Aqui eu mando pegar o número e tirar os pontos e hifens caso tenha.&lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Decompondo o comando&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Nome: &lt;/b&gt;Translate&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Parâmetro1: &lt;/b&gt;Conjunto de caracteres a serem analisados&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Parâmetro2:&amp;nbsp;&lt;/b&gt;Caracteres dos quais substituiram na mesma ordem.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
O comando&amp;nbsp;translate utilizado acima, é do postgresql, por sua vez, é possível que tenham em linguagens de programação ou banco de dados o mesmo nome com a mesma função.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/3850580649882424500/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2012/01/substituir-string-por-outra-string.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/3850580649882424500'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/3850580649882424500'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2012/01/substituir-string-por-outra-string.html' title='Substituir String por outra String'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-3096480450925576633</id><published>2011-12-19T05:52:00.000-08:00</published><updated>2011-12-20T10:40:45.305-08:00</updated><title type='text'>Instalando a versão PostGreSQL-8.2.23 no Ubuntu 10.04 LTS</title><content type='html'>&lt;div&gt;
&lt;div dir=&quot;ltr&quot; id=&quot;internal-source-marker_0.9831268035341054&quot; style=&quot;background-color: transparent; margin-bottom: 0pt; margin-top: 0pt; text-align: center;&quot;&gt;
&lt;span style=&quot;background-color: transparent; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial; font-size: large; text-decoration: none; white-space: pre-wrap;&quot;&gt;&lt;b&gt;&lt;br /&gt;Instalação&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial; white-space: pre-wrap;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial; white-space: pre-wrap;&quot;&gt;            A grande jogada nesta instalação, é instalar uma versão de &lt;b&gt;postgresql, &lt;/b&gt;da qual, os repositórios do ubuntu não possue. Para a versão de linux que vamos trabalhar, a 10.04 LTS, o postgresql liberado é o &lt;b&gt;8.2.7&lt;/b&gt; e vamos atualizar para último da categoria &lt;b&gt;8.2.23&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;1) Baixar ou enviar os fontes do postgres para máquina a ser instalado;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: 15px; font-weight: bold; white-space: pre-wrap;&quot;&gt;Repositório fpt oficial para download&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;a href=&quot;ftp://ftp.postgresql.org/pub/source&quot;&gt;ftp://ftp.postgresql.org/pub/source&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Verdana; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Verdana; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Comando - Para descompactar&lt;/span&gt;&lt;/div&gt;
$ sudo -s&lt;br /&gt;
$ cd /usr/src&lt;br /&gt;
$ tar jxvf /home/trabin/postgresql-8.2.23.tar.bz2Obs: Mova a pasta criada na descompactação para o seguinte caminho /usr/src/&lt;br /&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;2) &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Para que possamos criar um clusters em LATIN1 é preciso ajustar a language do sistema operacional.&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Comando&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$sudo apt-get install language-support-pt&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; white-space: pre-wrap;&quot;&gt;$sudo echo &quot;pt_BR.ISO-8859-1 ISO-8859-1&quot; &amp;gt;&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/var/lib/locales/supported.d/pt&lt;/span&gt;&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; white-space: pre-wrap;&quot;&gt;$sudo localedef -i pt_BR -c -f ISO-8859-1 pt_BR&lt;/span&gt;&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; white-space: pre-wrap;&quot;&gt;Por fim, edite o arquivo /etc/default/locale e altere&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;background-color: transparent; margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;De:&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;background-color: transparent; margin-bottom: 0pt; margin-left: 36pt; margin-top: 0pt; text-align: justify; text-indent: 36pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;LANG=&quot;pt_BR.UTF-8&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;background-color: transparent; margin-bottom: 0pt; margin-left: 36pt; margin-top: 0pt; text-align: justify; text-indent: 36pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;LANGUAGE=&quot;pt_BR:pt:en&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;background-color: transparent; margin-bottom: 0pt; margin-top: 0pt; text-align: justify; text-indent: 36pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Para:&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;background-color: transparent; margin-bottom: 0pt; margin-left: 36pt; margin-top: 0pt; text-align: justify; text-indent: 36pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;LANG=&quot;pt_BR.ISO-8859-1&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;background-color: transparent; margin-bottom: 0pt; margin-left: 36pt; margin-top: 0pt; text-align: justify; text-indent: 36pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;LANGUAGE=&quot;pt_BR:pt:en&quot;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;b&gt;3) Instalação do PostgreSQL 8.2 dos repositórios da versão &quot;hardy&quot;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Comando:&lt;/b&gt;&lt;br /&gt;
$ sudo -s&lt;br /&gt;
$ echo &quot;deb&lt;a href=&quot;http://archive.ubuntu.com/ubuntu&quot;&gt; http://archive.ubuntu.com/ubuntu&lt;/a&gt; hardy main universe&quot; &amp;gt; /etc/apt/sources.list.d/ubuntu-8.04.list&lt;br /&gt;
$ apt-get update -o APT::Cache-Limit=&quot;50331648&quot;&lt;br /&gt;
$ apt-get install postgresql-8.2&lt;br /&gt;
$ rm /etc/apt/sources.list.d/ubuntu-8.04.list&lt;br /&gt;
$ apt-get update&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;b) Instalação Compilador + Libs necessárias para compilar o PG:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Comando:&lt;/b&gt;$ sudo apt-get install build-essential libreadline-dev zlib1g-dev flex bison libssl-dev vim&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;b&gt;c) Compilação / Instalação do PostgreSQL 8.2 &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Obs:&lt;/b&gt;  Verifique se você esta no seguinte caminho /usr/src/postgresql-8.2.23&lt;br /&gt;
&lt;b&gt;Comando:&lt;/b&gt;&lt;br /&gt;
./configure&lt;br /&gt;
make&lt;br /&gt;
su&lt;br /&gt;
make install&lt;br /&gt;
adduser postgres&lt;br /&gt;
mkdir /usr/local/pgsql/data&lt;br /&gt;
chown postgres /usr/local/pgsql/data&lt;br /&gt;
su - postgres&lt;br /&gt;
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data&lt;br /&gt;
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data &amp;gt;logfile 2&amp;gt;&amp;amp;1 &amp;amp; &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;d) Incluindo a senha ao postgresComando&lt;/b&gt;&lt;br /&gt;
sudo su postgres -c psql postgres ALTER USER postgres WITH PASSWORD ‘sua senha’; &lt;br /&gt;
\q;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-size: 16px; font-style: italic; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;e)&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; Remover o cluster atual do 8.2 &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;(Só na primeira)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ sudo pg_dropcluster --stop 8.2 main&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;f)&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; Verificar tamanho do bloco da partição onde será instalado o cluster&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ sudo blockdev --getbsz /dev/sda1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;4096&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;g)&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; Verificando que o tamanho do bloco da partição &quot;/dev/sda1&quot; é &quot;4096&quot; vamos customizar a compilação do PostgreSQL para que também utilize esse tamanho de bloco&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ sudo -s&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ cd /usr/src/postgresql-8.2.23&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ vim src/include/pg_config_manual.h &amp;nbsp;&amp;nbsp;(neste ponto iremos editar o arquivo)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Alterar o&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;#define BLCKSZ &amp;nbsp;8192&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;para&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;#define BLCKSZ &amp;nbsp;4096&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;(salvar e sair)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;h)&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; Compilar / Instalar o PostgreSQL dentro da infra-estrutura do Ubuntu/Debian&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ sudo -s&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ cd /usr/src/postgresql-8.2.23&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ ./configure &#39;--prefix=/usr&#39; &#39;--includedir=/usr/include&#39; &#39;--mandir=/usr/share/man&#39; &#39;--infodir=/usr/share/info&#39; &#39;--sysconfdir=/etc&#39; &#39;--localstatedir=/var&#39; &#39;--libexecdir=/usr/lib/postgresql-8.2&#39; &#39;--srcdir=.&#39; &#39;--mandir=/usr/share/postgresql/8.2/man&#39; &#39;--with-docdir=/usr/share/doc/postgresql-doc-8.2&#39; &#39;--datadir=/usr/share/postgresql/8.2&#39; &#39;--bindir=/usr/lib/postgresql/8.2/bin&#39; &#39;--libdir=/usr/lib/postgresql/8.2/lib&#39; &#39;--includedir=/usr/include/postgresql/&#39; &#39;--enable-integer-datetimes&#39; &#39;--with-openssl&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ make&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ make install&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ exit&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;i) &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Depois de compilado e instalado agora vamos criar o novo Cluster&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ sudo pg_createcluster -e LATIN1 8.2 main&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ sudo /etc/init.d/postgresql-8.2 start&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;j)&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; Neste ponto já temos o novo cluster operacional, vamos verificar:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ pg_lsclusters&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Version Cluster &amp;nbsp;&amp;nbsp;Port Status Owner &amp;nbsp;&amp;nbsp;&amp;nbsp;Data directory &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;&amp;nbsp;&amp;nbsp;Log file&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: xx-small;&quot;&gt;8.2 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;main &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5432 online postgres /var/lib/postgresql/8.2/main &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/var/log/postgresql/postgresql-8.2-main.log&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;(Observe que o &quot;Status&quot; está &quot;online&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;l)&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; Agora algumas configurações básicas no seu PostgreSQL:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ sudo nano /etc/postgresql/8.2/main/&lt;b&gt;postgresql.conf&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;listen_addresses = &#39;*&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;ssl = false&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;log_line_prefix = &#39;%t [%p]: [%l-1] user=%u,db=%d &#39;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;autovacuum = off&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ sudo nano /etc/postgresql/8.2/main/&lt;b&gt;pg_hba.conf&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;# Database administrative login by UNIX sockets&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;#local &amp;nbsp;&amp;nbsp;all &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;postgres &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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ident sameuser&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;# TYPE &amp;nbsp;DATABASE &amp;nbsp;&amp;nbsp;&amp;nbsp;USER &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CIDR-ADDRESS &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;METHOD&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-size: 12px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;# &quot;local&quot; is for Unix domain socket connections only&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-size: 12px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;local &amp;nbsp;&amp;nbsp;all &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;trust&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-size: 12px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;# IPv4 local connections:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-size: 12px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;host &amp;nbsp;&amp;nbsp;&amp;nbsp;all &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;all &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://127.0.0.1/32&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-size: 12px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-size: 12px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;127.0.0.1/32&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-size: 12px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;trust&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-size: 12px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;# IPv6 local connections:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-size: 12px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;host &amp;nbsp;&amp;nbsp;&amp;nbsp;all &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;::1/128 &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;trust&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ sudo /etc/init.d/postgresql-8.2 restart&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;m)&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; Feito todas etapas agora temos o novo cluster com a versão 8.2.23 compilada pronta para uso&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ psql -U postgres -l&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;List of databases&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;Name &amp;nbsp;&amp;nbsp;&amp;nbsp;| &amp;nbsp;Owner &amp;nbsp;&amp;nbsp;| Encoding&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;-----------+----------+----------&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;postgres &amp;nbsp;| postgres | LATIN1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;template0 | postgres | LATIN1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;template1 | postgres | LATIN1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;(3 rows)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$ psql -U postgres&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Welcome to psql 8.2.23, the PostgreSQL interactive terminal.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Type: &amp;nbsp;\copyright for distribution terms&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;\h for help with SQL commands&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;\? for help with psql commands&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;\g or terminate with semicolon to execute query&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;\q to quit&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;postgres=# select version();&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;version &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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;-------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;PostgreSQL 8.2.23 on i686-pc-linux-gnu, compiled by GCC gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;(1 row)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;div style=&quot;text-align: center;&quot;&gt;
Este material é cópia alterada do documento postado no blog de um amigo de Porto Alegre.&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;b&gt;Fonte: Fabrízio de Royes Mello&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/3096480450925576633/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2011/12/instalando-versao-postgresql-8223-no.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/3096480450925576633'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/3096480450925576633'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2011/12/instalando-versao-postgresql-8223-no.html' title='Instalando a versão PostGreSQL-8.2.23 no Ubuntu 10.04 LTS'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-8919436878378872247</id><published>2011-12-16T02:33:00.000-08:00</published><updated>2011-12-16T02:34:38.866-08:00</updated><title type='text'>PostGreSQL parou na atualização do Windows Server 2008</title><content type='html'>Uma informação interessante e relevante sobre atualização de sistemas operacionais. Não façam se não souberem fazer! Isto é claro, se o suporte técnico já não deixou configurado para fazer sempre.&lt;br /&gt;Foi bem isto que aconteceu com um dos nossos clientes, ele tem um servidor windows server 2008, onde, ontem pela madrugada, se atualizou e mexeu na memória compartilhada do sistema operacional. Com o postgresql, usa parte desta memória, ao tentar startar seu serviço não conseguiu. Bom, deixei o arquivos &lt;b&gt;postgresql.conf &lt;/b&gt;original no lugar do que alteramos. Isto fez voltar o banco, mas não ficou com a nossa configuração.&lt;br /&gt;Eu ainda não achei o lugar no windows para corrigir este problema. Assim que encontrar posto aqui.</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/8919436878378872247/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2011/12/postgresql-parou-na-atualizacao-do.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/8919436878378872247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/8919436878378872247'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2011/12/postgresql-parou-na-atualizacao-do.html' title='PostGreSQL parou na atualização do Windows Server 2008'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-1267590822208275175</id><published>2011-10-04T11:23:00.000-07:00</published><updated>2011-10-04T12:58:46.307-07:00</updated><title type='text'>SCP - Copiar Arquivos/Diretórios Entre Máquinas</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Pessoal, vim dar minha a pequena contribuição no mundo linux. Hoje mostro como fazer uma cópia de uma pasta inteira que esta em uma máquina remota para dentro da sua máquina.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;Para tal faça:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;scp -r 192.168.1.109:/opt/backups/ /opt/backups/&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;scp&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;É o comando que vem com a instalação do ssh na máquina remota;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;-r&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;É critério que indica a cópia de diretórios e não um arquivo;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;192.168.1.109:/opt/backups/&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Assim diretamente, você digita o ip + o caminho de onde deseja copiar o diretório da máquina remota;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/opt/backups/&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;É onde o diretório vai ser gravado na máquina local.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;A questão de criação dos diretórios e suas permissões, eu não aborto aqui. Ainda é possível usar o &lt;b&gt;rsync, &lt;/b&gt;onde bem configurado é mais eficiente que o &lt;b&gt;scp.&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/1267590822208275175/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2011/10/scp-copiar-arquivosdiretorios-entre.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/1267590822208275175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/1267590822208275175'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2011/10/scp-copiar-arquivosdiretorios-entre.html' title='SCP - Copiar Arquivos/Diretórios Entre Máquinas'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-2106025453209882294</id><published>2011-06-27T12:53:00.001-07:00</published><updated>2011-06-27T12:58:18.010-07:00</updated><title type='text'>Comandos usados do POSTGRESQL em SHELL LINUX</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ol style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;Acessar o linux e usar o usuário postgresql&lt;br /&gt;
para ações abaixo:&lt;/b&gt;&lt;br /&gt;
su postgres&lt;br /&gt;
postgres: digitar a senha&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;Para criar um banco a partir do template &amp;nbsp;faça:&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;div style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;createdb nomedb -T template0 -e LATIN1 -O postgres;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;Para restaurar um banco a partir de um&lt;br /&gt;
arquivo de bkp, faça:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
pg_restore -i -h localhost -p 5432&lt;br /&gt;
-U postgres -d nomedb &amp;nbsp;mnt/dados/nomearquivo.backup;&lt;br /&gt;
&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;Para criar um arquivo bkp de um banco, faça:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
pg_dump -Fc -Z9 -U postgres -h localhost -f&lt;br /&gt;
/mnt/dados/nomearquivo.bkp nomedb&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;Para entrar, no banco de dados, e manipulá-lo,&lt;br /&gt;
por exemplo: &quot;TrabinEnxxe&quot;, faça:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
psql -d nomedb&lt;br /&gt;
&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;Para gerar um vaccum do banco faça:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;#-d base : para escolher o banco de dados;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;#-f : vacuum full;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;#-z - vacuum analyze;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;#-v : verbose;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;#-h : servidor remoto postgres;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;#-U : login do usuarioo do banco.&lt;br /&gt;
#-a : passa em todos bancos de dados; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;vacuumdb -d nomedb -U postgres -q -z&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: xx-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: xx-small;&quot;&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/2106025453209882294/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2011/06/acessar-o-linux-e-usar-o-usuario.html#comment-form' title='3 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/2106025453209882294'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/2106025453209882294'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2011/06/acessar-o-linux-e-usar-o-usuario.html' title='Comandos usados do POSTGRESQL em SHELL LINUX'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-1118413834236881708</id><published>2011-06-15T12:29:00.000-07:00</published><updated>2011-06-16T05:23:58.265-07:00</updated><title type='text'>Instalando a versão PostGreSQL-8.4 no Ubuntu 10.04 LTS</title><content type='html'>&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div id=&quot;internal-source-marker_0.864549157442525&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt; text-align: center;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: white; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Instalando a versão PostGreSQL-8.4 no Ubuntu 10.04 LTS  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-top: 0pt; text-align: center;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: white; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Este tutorial, ajuda na instalação do postgresql-8.4, via shell no ubuntu 10.04 LTS&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;background-color: transparent; color: white; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: italic; font-weight: normal; list-style-type: decimal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Comando para instalação&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: italic; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;sudo apt-get install postgresql-8.4 postgresql-client-8.4  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: italic; font-weight: normal; list-style-type: decimal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Comando para cadastrar a senha do usuário postgres&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: italic; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;sudo su postgres -c psql postgres ALTER USER postgres WITH PASSWORD ‘password’; &lt;br class=&quot;kix-line-break&quot; /&gt;\q;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;ol start=&quot;3&quot;&gt;&lt;li style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: italic; font-weight: normal; list-style-type: decimal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Para que possamos criar um clusters em LATIN1 é preciso ajustar a language do sistema operacional. &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; sudo apt-get install language-support-pt&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;br class=&quot;kix-line-break&quot; /&gt; sudo echo &quot;pt_BR.ISO-8859-1 ISO-8859-1&quot; &amp;gt;&amp;gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;    /var/lib/locales/supported.d/pt&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;span style=&quot;background-color: transparent; color: white; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: white; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;sudo localedef -i pt_BR -c -f ISO-8859-1 pt_BR  &lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;background-color: transparent; color: white; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: white; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Por fim, edite o arquivo /etc/default/locale e altere&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: white; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;De:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 36pt; margin-top: 0pt; text-align: justify; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: white; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;LANG=&quot;pt_BR.UTF-8&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 36pt; margin-top: 0pt; text-align: justify; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: white; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;LANGUAGE=&quot;pt_BR:pt:en&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-top: 0pt; text-align: justify; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: white; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Para:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 36pt; margin-top: 0pt; text-align: justify; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: white; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;LANG=&quot;pt_BR.ISO-8859-1&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 36pt; margin-top: 0pt; text-align: justify; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: white; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;LANGUAGE=&quot;pt_BR:pt:en&quot;&lt;/span&gt;&lt;/div&gt;&lt;ol start=&quot;4&quot;&gt;&lt;li style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: italic; font-weight: normal; list-style-type: decimal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Apos, vamos dropar o cluster criado pela instalação, onde é feito usando o UTF8 como linguagem.  &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Dropando...&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;pg_dropcluster 8.4 main&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;br class=&quot;kix-line-break&quot; /&gt;Criando...&lt;br class=&quot;kix-line-break&quot; /&gt;pg_createcluster -e LATIN1 8.4 main&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: italic; font-weight: normal; list-style-type: decimal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Agora é preciso configurar o arquivo &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;pg_hba.conf e postgresql.cof, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;para que os outros usuários possam acessar o banco de dados no servidor. Pra isto, edite os arquivos e deixe-os parecido com estas linhas abaixo:&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;pg_hba.conf &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;# &quot;local&quot; is for Unix domain socket connections only &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal; font-weight: bold; white-space: pre-wrap;&quot;&gt;local &amp;nbsp;&amp;nbsp;all &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ident &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal; font-weight: bold; white-space: pre-wrap;&quot;&gt;# IPv4 local connections: &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal; font-weight: bold; white-space: pre-wrap;&quot;&gt;host &amp;nbsp;&amp;nbsp;&amp;nbsp;all &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;127.0.0.1/32 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;trust &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal; font-weight: bold; white-space: pre-wrap;&quot;&gt;host &amp;nbsp;&amp;nbsp;&amp;nbsp;all &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;192.168.1.0/24 &amp;nbsp;&amp;nbsp;trust &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal; font-weight: bold; white-space: pre-wrap;&quot;&gt;# IPv6 local connections: &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal; font-weight: bold; white-space: pre-wrap;&quot;&gt;host &amp;nbsp;&amp;nbsp;&amp;nbsp;all &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;::1/128 &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;trust&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;span style=&quot;background-color: transparent; color: white; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;                   &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;postgresql.conf    &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;#listen_addresses = &#39;*&#39; &amp;nbsp;&amp;nbsp;# what IP address(es) to listen on;&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;br class=&quot;kix-line-break&quot; /&gt;Obs:&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; Ao final de tudo execute o comando &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: &#39;Courier New&#39;; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;sudo /etc/init.d/postgresql-8.4 restart&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;br class=&quot;kix-line-break&quot; /&gt;Pronto, neste ponto, já é possível acessar o banco e tanto localmente quanto remotamente.&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;br class=&quot;kix-line-break&quot; /&gt;O nosso banco já esta configurado e rondando.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/1118413834236881708/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2011/06/instalando-versao-postgresql-84-no.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/1118413834236881708'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/1118413834236881708'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2011/06/instalando-versao-postgresql-84-no.html' title='Instalando a versão PostGreSQL-8.4 no Ubuntu 10.04 LTS'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-764426918659957452</id><published>2011-06-10T13:03:00.000-07:00</published><updated>2011-06-10T13:03:35.060-07:00</updated><title type='text'></title><content type='html'>Durante algumas semanas, na tranquilidade, eu venho ajustando um servidor com &lt;b&gt;Ubuntu Server 10.04 LTS + PostGreSQL&lt;/b&gt;. &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Restaurei meus bancos de dados&lt;/li&gt;
&lt;li&gt;Copiei os arquivos do servidor windows&lt;/li&gt;
&lt;li&gt;Configurei o samba, para que todos que usam windows, pudessem visualizar o linux.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;&lt;div&gt;Depois de tudo acima, tive que fazer um script de backup para copiar periodicamente arquivos fontes dos projetos feitos em delphi de todas as nossas máquinas windows e criar cópias dos bancos postgresql mais importantes dos quais nós usamos.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Criar um script, não é galho, mas algumas coisas que faço no postgresql ou em delphi gostaria de fazer no script e tomei um laço, mas esta pronto.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;#O processo a baixo coloca na tela um mensagem da Data/Hora inicial do processo&lt;/div&gt;&lt;div&gt;DATA=`date +%Y-%m-%d`&lt;/div&gt;&lt;br /&gt;
HORA=`date +%H:%M`&lt;br /&gt;
echo &quot;+++ .&quot;&lt;br /&gt;
echo &quot;+++ Data/Hora do inicio da copia. &quot;$DATA $HORA&lt;br /&gt;
echo &quot;+++ .&quot;&lt;br /&gt;
&lt;br /&gt;
#Este processo aqui, limpa todos os arquivos com extensão bkp com mais de 3 dias de criação&lt;br /&gt;
echo &quot;Executando limpeza das copias dos bancos de dados a mais de 3 dias&quot;&lt;br /&gt;
find /opt/Base_de_Dados/ -name &#39;*.bkp&#39; -ctime +3 -exec rm -fv {} \;&lt;br /&gt;
&lt;br /&gt;
##Data e Hora para fazer os backup do banco de dados&lt;br /&gt;
DATA=`date +%Y%m%d`&lt;br /&gt;
HORA=`date +%H%M`&lt;br /&gt;
echo &quot;+++ Gerando copia dos bancos mais importantes da empresa&quot;&lt;br /&gt;
pg_dump -Fc -Z9 -U postgres -h localhost -f /opt/Base_de_Dados/NomeDoArquivo_$DATA$HORA.bkp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;Nome_do_Banco&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;div&gt;#O processo a baixo coloca na tela um mensagem da Data/Hora fim do processo&lt;/div&gt;&lt;div&gt;DATA=`date +%Y-%m-%d`&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;HORA=`date +%H:%M`&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;echo &quot;+++ .&quot;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;echo &quot;+++ Data/Hora do fim da copia. &quot;$DATA $HORA&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;echo &quot;+++ .&quot;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/764426918659957452/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2011/06/durante-algumas-semanas-na.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/764426918659957452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/764426918659957452'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2011/06/durante-algumas-semanas-na.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-6891105975120067136</id><published>2011-03-18T10:34:00.000-07:00</published><updated>2011-03-18T11:04:14.336-07:00</updated><title type='text'>Campanha - USEM LINUX</title><content type='html'>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A idéia de usar linux, veio a sete anos atrás, onde a minha terceira máquina, um pentium 100, com 256MB de RAM, recebeu um dual boot entre &lt;b&gt;Conectiva10 e WindowsXP.&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/b&gt;Durante muitos anos, fui tentando usar o linux e achar uma forma dele ficar definitivamente com sistema operacional preferencial, foi difícil!!! Foi ai, que o aprufundamento do uso de um dos melhores bancos de dados, o &lt;b&gt;postgresql, &lt;/b&gt;que a empresa onde trabalho viu a necessidade de começar a estudar este sistema operacional. Outra grande motivo, foi a necessidade de alguns clientes que não aguentavam mais com os vírus que tem no windows e nos pediram para instalar e gerenciar o linux pra eles.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; No ano de 2010, fiz um curso na capital do meu estado &lt;b&gt;Porto Alegre - RS, &lt;/b&gt;onde estudei desde o módulo iniciante até o avançado. Foi ai, que realmente me senti a vontade e nunca mais mudei o sistema operacional.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Atualmente, uso &lt;b&gt;Ubuntu - Desktop 10.04 LTS, &lt;/b&gt;como sistema host e virtualizo um xp, para poder trabalhar com a linguagem de programação que me sustenta &lt;b&gt;Delphi.&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/b&gt;Com o tempo, consegui deixar tudo redondinho, ter uma maquina virtualizada, foi também um grande estudo meu. Não é fácil implantar tecnologias como estas a usuários comuns ou entidades empresariais como a que trabalho, sou obrigado a provar que funciona e também sentir que posso dominar e manter tal tecnologia, a ponto de ser uma referência local no que emprego e luto para que seja prática usual a todos.&lt;br /&gt;
&lt;b&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Pessoal, &lt;/b&gt;sei que não é facil usar linux, mas esta melhorando, os programadores estão cada vez mais facilitando para usuários comuns o manusei do sistema. Bom, por mim, eu já me viro 100% na unha, ou seja, shell é a minha casa, me acho melhor do que no desktop.&lt;br /&gt;
&lt;b&gt;USEM LINUX!!!&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/6891105975120067136/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2011/03/campanha-usem-linux.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/6891105975120067136'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/6891105975120067136'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2011/03/campanha-usem-linux.html' title='Campanha - USEM LINUX'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-8990908307532488933</id><published>2011-03-09T06:07:00.000-08:00</published><updated>2011-03-09T09:20:02.494-08:00</updated><title type='text'>SSH - Erro de autenticação</title><content type='html'>&lt;b&gt;Nesta postagem, eu explico como eu corrigi um erro de autenticação do SSH. &lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Os erros de autenticação, pra mim, até hoje, foi somente porque eu mexi onde não deveria mexer. &lt;br /&gt;
Vendo artigos na internet e em vários sites, todos recomendam a exclusão do arquivo &lt;b&gt;/root/.ssh/known_hosts&lt;/b&gt;. Este arquivo grava as chaves de acesso para autenticação. &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Fiz tudo que foi descrito acima e ainda continuo com o mesmo erro, não consigo me logar no servidor. &lt;b&gt;A solução para este galho&lt;/b&gt;, foi também na máquina onde uso para me logar, também excluir este arquivo. Este foi o modo que resolvi o meu problema, mas sei, que se eu entrasse no arquivo do qual foi excluído, e excluísse somente a linha referente ao ip da máquina de acesso resolveria também.</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/8990908307532488933/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2011/03/ssh-erro-de-autenticacao.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/8990908307532488933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/8990908307532488933'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2011/03/ssh-erro-de-autenticacao.html' title='SSH - Erro de autenticação'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4017673185899003667.post-517561077364229410</id><published>2011-02-28T03:51:00.000-08:00</published><updated>2011-03-02T05:09:47.681-08:00</updated><title type='text'>http://lgerardlucas.blogspot.com/</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;Instalação Ubuntu Server 10.04 LTS&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Neste documento, é definido a preparação de um servidor Linux  para ser um servidor de banco de dados PostGreSQL.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Sistema Operacional&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Linux - Ubuntu Server 10.04 LTS - Versão com 5 anos de atualizações&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Dados para Instalação:&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Nome do usuário:&lt;/b&gt; servidor&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Senha: &lt;/b&gt;*****&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Teclado:&lt;/b&gt; Portugues&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Login: &lt;/b&gt;Pedir senha e usuário&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Desktop:&lt;/b&gt; Sem Desktop&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Sistema de Arquivo Recomendado: &lt;/b&gt;Ext3 ou Ext4(Padrão)&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Preferêncialmente usar Ext4;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Este sistema de arquivo, tem melhor desempenho para arquiteturas 64Bits;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Totalmente compatível com Ext3;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Melhor segurança nos processo de I/O.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Linguagem: &lt;/b&gt;Português - Brazil&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;li&gt;&lt;b&gt;Nº de hds que a máquina possui&lt;/b&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;b&gt;Analise: &lt;/b&gt;No meu servidor, há dois hds de 150GB cada, com isto, foi feito o seguinte processo:&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;No &lt;b&gt;sda1 &lt;/b&gt;foi instalado do sistema operacional mais a &lt;b&gt;swap&lt;/b&gt;.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;No &lt;b&gt;sdb1&lt;/b&gt; foi formatado e montado no &lt;b&gt;/mnt/dados&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;li&gt;&lt;b&gt;Configurações para os procedimentos acima&lt;/b&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;b&gt;Reconhecimento: &lt;/b&gt;Foi usado &lt;b&gt;fdisk -l&lt;/b&gt; para listar os hds existentes. Neste ponto foi reconhecido dois, o sda e o sdb.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Preparação: &lt;/b&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;Foi criado o disco com o comando &lt;b&gt;fdisk /dev/sdb1;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Foi dado um sistema operacional &lt;b&gt;ext4;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Foi formatado o discso em questão com &lt;b&gt;mkfs.ext4 /dev/sdb1&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Foi criado um diretório em &lt;b&gt;/mnt/dados &lt;/b&gt;com permissão 777&lt;/li&gt;
&lt;li&gt;Foi feito a montagem usando o seguinte comando no arquivo &lt;b&gt;/etc/fstab&lt;br /&gt;
Comando:&lt;/b&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;# Particao referente ao segundo hd sdb1 para gravar dados do banco postgres&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-family: courier new; font-size: x-small;&quot;&gt;/dev/sdb1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /mnt/dados/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ext4&amp;nbsp;&amp;nbsp;&amp;nbsp; auto,user,exec&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Sistema operacional, após a instalação:&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Atualizar todo o sistema&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Comando:&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;sudo apt-get update;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;sudo apt-get upgrade;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Instalação e configuração de programas&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;SSH: &lt;/b&gt;Instalar o serviço ssh para acesso remoto, tanto do nxmachine como por linha de comando.&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Comando: &lt;/b&gt;apt-get install ssh&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;PORTA: &lt;/b&gt;Liberar  no modem a porta 22(Ou definir uma porta mais segura) apontando para o  ip da máquina servidor de acesso, que deverá ser uma, pré-definida e que  tenha linux. &lt;b&gt;Obs: &lt;/b&gt;Esta configuração, servirá para uso dos programas acima citados.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;SAMBA: &lt;/b&gt;Instalar  serviço samba Versão 3.4 ou superior(A partir desta versão, já suporta  acesso a máquinas com Windown 7), para que máquinas windows enxergem as  máquinas linux. &lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Comando:&lt;/b&gt; sudo apt-get install samba&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Menu: &lt;/b&gt;Sistema/Administração/Gerenciador de pacotes Synaptic&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Arquivo: &lt;/b&gt;/etc/samba/smb.conf&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Conteúdo:&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: courier new; font-size: x-small;&quot;&gt;[global]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; workgroup = meu grupo&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; server string = %h Servidor Linux (Servidor)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dns proxy = no&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name resolve order = lmhosts wins bcast host&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; interfaces = 127.0.0.0/8 eth0&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cups options = raw&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; socket options = TCP_NODELAY&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; security = share&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printing = cups&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printcap name = cups&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printcap cache time = 750&lt;br /&gt;
[servidor]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; comment = Servidor Linux - PostGreSQL8.2&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; path = /home/servidor/.wine/drive_c/&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; browseable = yes&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; guest ok = yes&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writeable = yes&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; read only = no&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create mask = 0777&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; directory mask = 0777&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public = yes&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Comando:&lt;/b&gt; Utilizar a linha de comando a seguir para aplicar a configurações feitas no samba /etc/init.d/smbd restart, stop ou start;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Serviço smbfs:&lt;/b&gt; Instalar o serviço smbfs. Algumas vezes, este serviço não é instalado junto com o samba e, é com ele, que a rede funciona;&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Comando: &lt;/b&gt;apt-get install smbfs&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;FSTAB&lt;/b&gt;: Arquivo responsável por manter as montagens feitas entre máquinas, preferencialmente criadas na pasta &lt;b&gt;/mnt&lt;/b&gt;.  Neste ponto é feito a montagem das estão no Servidor compartilhadas.  Isto garante, o acesso aos arquivos necessários ao sistema&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Arquivo: &lt;/b&gt;sudo /etc/fstab&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Conteúdo: &lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: courier new; font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;#Apontar para o ip do Servidor&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new; font-size: x-small;&quot;&gt;//192.168.1.250/Compartilhamento/&amp;nbsp;&amp;nbsp; /home/trabin/.wine/drive_c/pasta&amp;nbsp; smbfs user=servidor,password=*****,user,rw,uid=1000,&lt;br /&gt;
gid=1000,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: courier new; font-size: x-small;&quot;&gt;umask=022 0 0&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;b&gt;Obs&lt;/b&gt;:  Após deixar o arquivo citado configurado, criar dentro do caminho onde  haverá a montagem, o diretório da montagem e dar permissão 7777&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;ol start=&quot;3&quot;&gt;&lt;li style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Rede &lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Rede Linux:&lt;/b&gt; Configuração responsável por introduzir o sistema operacional linux na rede. &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Arquivo: &lt;/b&gt;/etc/network/interfaces &lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Uso: &lt;/b&gt;Arquivo responsável por colocar na rede a máquina em questão, no seu ip, máscara e gateway correto;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Placas: &lt;/b&gt;Na  configuração abaixo, considero que a máquina tenha somente uma placa de  rede. Mesmo que tenha duas, o máximo que poderiamos fazer é dar outro  ip para a outra placa de rede.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Conteúdo do arquivo:&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: courier new; font-size: x-small;&quot;&gt;&lt;br /&gt;
auto lo&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br style=&quot;font-family: Courier New;&quot; /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: courier new; font-size: x-small;&quot;&gt;iface lo inet loopback &lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-family: courier new; font-size: x-small;&quot;&gt;auto eth0&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br style=&quot;font-family: Courier New;&quot; /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: courier new; font-size: x-small;&quot;&gt;iface eth0 inet static&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br style=&quot;font-family: Courier New;&quot; /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: courier new; font-size: x-small;&quot;&gt;address 192.168.1.250&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br style=&quot;font-family: Courier New;&quot; /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: courier new; font-size: x-small;&quot;&gt;netmask 255.255.255.0&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br style=&quot;font-family: Courier New;&quot; /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: courier new; font-size: x-small;&quot;&gt;gateway 192.168.1.1&lt;/span&gt;&lt;b&gt;&lt;br /&gt;
&lt;br /&gt;
Obs1: &lt;/b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Neste ponto, analisando as camadas do modelo&amp;nbsp; OSI, aqui seria a camada Sessão;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;li&gt;&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Arquivo:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: small;&quot;&gt; /etc/network/interfaces &lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Uso: &lt;/b&gt;Arquivo responsável por colocar na rede a máquina em questão, no seu ip, máscara e gateway correto;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Placas: &lt;/b&gt;Na  configuração abaixo, considero que a máquina tenha duas placas de rede,  e que iremos fazer uso das duas em um único ip. Se uma placa parar a  outra assume;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Conteúdo do arquivo: &lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;auto lo&lt;/span&gt;&lt;br style=&quot;font-family: Courier New;&quot; /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;iface lo inet loopback&lt;/span&gt;&lt;br style=&quot;font-family: Courier New;&quot; /&gt;&lt;br style=&quot;font-family: Courier New;&quot; /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;# Acesso a primeira interface de rede&lt;/span&gt;&lt;br style=&quot;font-family: Courier New;&quot; /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;auto bond0&lt;/span&gt;&lt;br style=&quot;font-family: Courier New;&quot; /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;iface bond0 inet static&lt;/span&gt;&lt;br style=&quot;font-family: Courier New;&quot; /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;address 192.168.1.251&lt;/span&gt;&lt;br style=&quot;font-family: Courier New;&quot; /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;netmask 255.255.255.0&lt;/span&gt;&lt;br style=&quot;font-family: Courier New;&quot; /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;gateway 192.168.1.1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Ativando e instalando módulos:&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Instalar: &lt;/b&gt;Para o gerenciamento de duas placas em um só ip, é preciso ter, isto no caso do Ubuntu, os módulos &lt;b&gt;ifenslave e bonding &lt;/b&gt;instalado e pra isto execute o comando: &lt;b&gt;aptitude ifenslave bonding&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Ativando:&amp;nbsp; &lt;/b&gt;Após a instalar os módulos acima, é preciso ativar o módulo &lt;b&gt;bonding.&lt;/b&gt; Pra isto, no meu caso, foi&amp;nbsp; criado um arquivo sh para fazer as ativações e associações necessárias, com o seguinte conteúdo: &lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b style=&quot;font-family: Courier New;&quot;&gt;Ativa o módulo bonding&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new; font-size: x-small;&quot;&gt;modprobe bonding&lt;br /&gt;
&lt;b&gt;Vincula ao serviço bond as placas de rede 0 e 1&lt;/b&gt;&lt;br /&gt;
ifenslave bond0 eth0&lt;br /&gt;
ifenslave bond0 eth1&lt;br /&gt;
&lt;b&gt;Ativa o vinculo acima criado&lt;/b&gt;&lt;br /&gt;
alias bond0 bonding&lt;br /&gt;
&lt;b&gt;Configurações do serviço bond&lt;/b&gt;&lt;br /&gt;
options bond0 miimon=1000 mode=1&lt;/span&gt;&lt;b&gt;Obs: &lt;/b&gt;O  arquivo acima, foi dado um nome com a extensão sh com permissão 777 e  colocado no diretório /mnt/init.d/, onde será executado ao ligar a  máquina.&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Arquivo: &lt;/b&gt;/etc/resolv.conf&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;b&gt;Uso: &lt;/b&gt;Arquivo responsável por resolver o DNS&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Conteúdo do Arquivo&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;&lt;b&gt;o&lt;/b&gt;ptions rotate&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;&amp;nbsp;nameserver 8.8.4.4&amp;nbsp; &lt;span style=&quot;font-size: xx-small;&quot;&gt;#&lt;span style=&quot;font-size: x-small;&quot;&gt;DNS Public da Google&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol&gt;&lt;ol start=&quot;3&quot;&gt;&lt;ol start=&quot;4&quot;&gt;&lt;ol start=&quot;4&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Arquivo: &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;/etc/hostname&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Uso:&lt;/b&gt; Arquivo responsável em dar um nome a máquina&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Conteúdo do arquivo:&lt;/b&gt; servidor&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;ol start=&quot;3&quot;&gt;&lt;ol start=&quot;4&quot;&gt;&lt;li&gt;&lt;b&gt;Comando para informações &lt;/b&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;b&gt;free -mt: &lt;/b&gt;Retorna o espaço total e livre em MB;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;df -h: &lt;/b&gt;Retorna o espaço total e livre em MB mais detalhado;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;dpkg -l: &lt;/b&gt;Mostra todos os pacotes instalados. &lt;b&gt;dpkg -l | grep ssh &lt;/b&gt;mostra se o pacote &lt;b&gt;ssh &lt;/b&gt;esta instalado;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;cat /proc/cpuinfo/:&lt;/b&gt; Mostra o conteúdo do arquivo que guarda os dados da máquina, como o processador;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;mount: &lt;/b&gt;Mostra informações como sistema de arquivo.&lt;/li&gt;
&lt;/ol&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;ol start=&quot;5&quot; style=&quot;margin-left: 80px;&quot;&gt;&lt;li&gt;&lt;b&gt;Desktop&lt;/b&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;&lt;b&gt;Instalação: &lt;/b&gt;Para  fins de acesso seguro e manutenção dos bancos de dados pelos  funcionários sem conhecimento do uso do servidores via linha de comando,  no final desta documentação, irei instalar o dektop no server digitando  o seguinte comando: &lt;br /&gt;
&lt;b&gt;sudo apt­get install ubuntu­desktop&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/ol&gt;&lt;br /&gt;
&lt;b&gt;Banco de dados&lt;/b&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;b&gt;Instalação PostgreSQL 8.2&lt;/b&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;&lt;ol style=&quot;margin-left: 40px;&quot;&gt;&lt;li&gt;&lt;b&gt;Preparação: &lt;/b&gt;Para instalar o PostgreSQL 8.2 no &lt;b&gt;Ubuntu Server 10.04&lt;/b&gt;,  é de fato que teremos de utilizar os repositórios do ubuntu 8.04, pois  para esta versão de postgresql a versão de linux, jás não possui os  repositórios necessários.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Sourceslis: &lt;/b&gt;Entra no arquivo &lt;b&gt;/etc/apt/soucer.list &lt;/b&gt;e incluir a seguinte linha dentro: &lt;b&gt;deb http://br.archive.ubuntu.com/ubuntu hardy main universe &lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Instalando:&lt;/b&gt;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;sudo apt­-get update&lt;/li&gt;
&lt;li&gt;sudo apt­-get install postgresql­8.2&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;Apos a instalação no ubuntu os arquivos do postgresql ficarão no seguinte caminho:&lt;br /&gt;
# &lt;b&gt;ls -l /var/lib/postgresql/8.2/main/&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif; font-size: x-small;&quot;&gt;drwx------ 5 postgres postgres 4096 2011-02-25 16:13 base&lt;br /&gt;
drwx------ 2 postgres postgres 4096 2011-02-25 16:14 global&lt;br /&gt;
drwx------ 2 postgres postgres 4096 2011-02-25 16:13 pg_clog&lt;br /&gt;
drwx------ 4 postgres postgres 4096 2011-02-25 16:13 pg_multixact&lt;br /&gt;
drwx------ 2 postgres postgres 4096 2011-02-25 16:13 pg_subtrans&lt;br /&gt;
drwx------ 2 postgres postgres 4096 2011-02-25 16:13 pg_tblspc&lt;br /&gt;
drwx------ 2 postgres postgres 4096 2011-02-25 16:13 pg_twophase&lt;br /&gt;
-rw------- 1 postgres postgres&amp;nbsp;&amp;nbsp;&amp;nbsp; 4 2011-02-25 16:13 PG_VERSION&lt;br /&gt;
drwx------ 3 postgres postgres 4096 2011-02-25 16:13 pg_xlog&lt;br /&gt;
-rw------- 1 postgres postgres&amp;nbsp; 125 2011-02-25 16:13 postmaster.opts&lt;br /&gt;
-rw------- 1 postgres postgres&amp;nbsp;&amp;nbsp; 54 2011-02-25 16:13 postmaster.pid&lt;br /&gt;
lrwxrwxrwx 1 root&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; root&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 36 2011-02-25 16:13 server.crt -&amp;gt; /etc/ssl/certs/ssl-cert-snakeoil.pem&lt;br /&gt;
lrwxrwxrwx 1 root&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; root&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 38 2011-02-25 16:13 server.key -&amp;gt; /etc/ssl/private/ssl-cert-snakeoil.key&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;li&gt;sudo apt­-get update&lt;/li&gt;
&lt;/ol&gt;&lt;li&gt;&lt;b&gt;Configuração Cluster&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;ol style=&quot;margin-left: 80px;&quot;&gt;&lt;li&gt;Entrei no soucer.list e incluir a seguinte linha&lt;br /&gt;
&lt;b&gt;deb &lt;a href=&quot;http://br.archive.ubuntu.com/ubuntu&quot; linkindex=&quot;17&quot; target=&quot;_blank&quot;&gt;http://br.archive.ubuntu.com/ubuntu&lt;/a&gt; hardy main universe&lt;/b&gt;&lt;br /&gt;
Isto me proporcionou a instalação do postgresql-8.2&lt;/li&gt;
&lt;li&gt;Após a instalação executei os seguintes comandos:&lt;br /&gt;
&lt;b&gt;# pg_lsclusters &lt;/b&gt;O resultado foi este: &lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;Version Cluster Port Status Owner&amp;nbsp;&amp;nbsp;&amp;nbsp; Data directory&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; Log file&lt;/span&gt;&lt;br style=&quot;font-family: Courier New;&quot; /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt; 8.2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; main&amp;nbsp;&amp;nbsp;&amp;nbsp; 5432 online postgres /var/lib/postgresql/8.2/main&amp;nbsp;&amp;nbsp;&amp;nbsp; /var/log/postgresql&lt;/span&gt;/postgresql-8.2-main.log&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Isto indica que meu cluster(agrupamento de bancos) esta ok. &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Verificando status do serviço postgres&lt;/b&gt;&lt;br /&gt;
# &lt;b&gt;/etc/init.d/postgresql-8.2 status&lt;/b&gt;&lt;br /&gt;
O resultado foi este: Running clusters: 8.2/main &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Excluindo o cluster, já que&amp;nbsp; a instalação e toda nova e não tem banco&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;# pg_dropcluster --stop 8.2 main&lt;/b&gt;&lt;br /&gt;
O resultado foi este: nada, a principio eu matei o meu cluster&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Listando os clusters existentes &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;# pg_lsclusters &lt;/b&gt;&lt;br /&gt;
O resultado foi este:&lt;br /&gt;
Version Cluster&amp;nbsp;&amp;nbsp; Port Status Owner&amp;nbsp;&amp;nbsp;&amp;nbsp; Data directory&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;&amp;nbsp;&amp;nbsp; Log file&lt;br /&gt;
&lt;b&gt;Agora já não possuo mais um cluster, ficanco pronto para criar um novo.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Nas  linhas abaixo, iremos mudar o econding do sistema operacional. Isto é  necessário para que o novo cluster seja criado no econding correto para o  nosso caso.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;# locale&lt;/b&gt;&lt;br /&gt;
LANG=pt_BR&lt;br /&gt;
LANGUAGE=pt_BR:pt:en&lt;br /&gt;
LC_CTYPE=”pt_BR”&lt;br /&gt;
LC_NUMERIC=”pt_BR”&lt;br /&gt;
LC_TIME=”pt_BR”&lt;br /&gt;
LC_COLLATE=”pt_BR”&lt;br /&gt;
LC_MONETARY=”pt_BR”&lt;br /&gt;
LC_MESSAGES=”pt_BR”&lt;br /&gt;
LC_PAPER=”pt_BR”&lt;br /&gt;
LC_NAME=”pt_BR”&lt;br /&gt;
LC_ADDRESS=”pt_BR”&lt;br /&gt;
LC_TELEPHONE=”pt_BR”&lt;br /&gt;
LC_MEASUREMENT=”pt_BR”&lt;br /&gt;
LC_IDENTIFICATION=”pt_BR”&lt;br /&gt;
LC_ALL= pt_BR.ISO-8859-1&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Criando  o novo cluster. A opção &quot;-e&quot; indica a criação, mas é possivel usar a  outras opção conforme man pg_createcluster, por exemplo para criar o  cluster em outro diretório. &quot;-d&quot;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;# pg_createcluster -e LATIN1 8.2 main&lt;/b&gt;&lt;br /&gt;
Creating new cluster (configuration: /etc/postgresql/8.2/main, data: /var/lib/postgresql/8.2/main)...&lt;br /&gt;
Moving configuration file /var/lib/postgresql/8.2/main/postgresql.conf to /etc/postgresql/8.2/main...&lt;br /&gt;
Moving configuration file /var/lib/postgresql/8.2/main/pg_hba.conf to /etc/postgresql/8.2/main...&lt;br /&gt;
Moving configuration file /var/lib/postgresql/8.2/main/pg_ident.conf to /etc/postgresql/8.2/main...&lt;br /&gt;
Configuring postgresql.conf to use port 5432...&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Logando com usuário postgres para trabalhar no banco&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;# su postgres&lt;/b&gt;&lt;br /&gt;
Entrei com usuário postgres&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Acessando o banco template1 para teste&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;# \c template1&lt;/b&gt;&lt;br /&gt;
Acessei um banco de dados&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Criando meu banco de dados&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;postgres =# CREATE DATABASE &quot;MeuBancoDeDados&quot;&lt;/b&gt;&lt;br /&gt;
Criei um banco de dados&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Analisando o encondig do banco&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;postgres =# \encoding &lt;/b&gt;LATIN1&lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; # su postgres&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Entrei com usuário postgres&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;#postgres =# \encoding &lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LATIN1&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Hoje é só isto que fiz, conforme vou evoluindo irei postar mais.&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://lgerardlucas.blogspot.com/feeds/517561077364229410/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://lgerardlucas.blogspot.com/2011/02/httpwwwbloggercomlgerardlucas.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/517561077364229410'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4017673185899003667/posts/default/517561077364229410'/><link rel='alternate' type='text/html' href='http://lgerardlucas.blogspot.com/2011/02/httpwwwbloggercomlgerardlucas.html' title='http://lgerardlucas.blogspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>