If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Large SQL file with up to 200mb

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-18-12, 09:35
ycavazin ycavazin is offline
Registered User
 
Join Date: Jun 2012
Posts: 2
Angry Large SQL file with up to 200mb

Hello folks,

I'm Brazilian and a friend of mine recommended this forum.

When I try to import that SQL file to my PostgreSQL database I get stuck.

It is a list of Postal Codes from Brazil. It's very large.

I can't see all of the contents, cuz it gets an error when I try to open it on excel.

I just can see some lines:

Code:
-- SQL Manager for PostgreSQL 5.1.0.3 
-- --------------------------------------- 
#NOME? 
#NOME? 
-- Version : PostgreSQL 8.4.10 on x86_64-pc-linux-gnu, compiled by GCC gcc-4.4.real (Debian 4.4.5-8) 4.4.5, 64-bit 



SET check_function_bodies = false; 
-- 
-- Definition for function sem_acentos (OID = 25419) : 
-- 
SET search_path = public, pg_catalog; 
CREATE FUNCTION public.sem_acentos ( 
string character varying 
) 
RETURNS varchar 
AS 
$body$ 
SELECT TRANSLATE($1, áéíóúàèìòùãõâêîôôäëïöüçÁÉÍÓÚÀÈÌÒÙÃÕÂÊÎÔÛÄËÏÖÜÇ, aeiouaeiouaoaeiooaeioucAEIOUAEIOUAOAEIOOAEIOUC) 
$body$ 
LANGUAGE sql; 
-- 
-- Structure for table tend_cidade (OID = 16940) : 
-- 
CREATE TABLE public.tend_cidade ( 
id_cidade integer NOT NULL, 
cidade varchar(100) NOT NULL, 
uf varchar(2) NOT NULL 
) WITHOUT OIDS; 
-- 
-- Structure for table tend_bairro (OID = 16943) : 
-- 
CREATE TABLE public.tend_bairro ( 
id_bairro integer NOT NULL, 
bairro varchar(50) NOT NULL, 
id_cidade integer NOT NULL 
) WITHOUT OIDS; 
-- 
-- Structure for table tend_endereco (OID = 16946) : 
-- 
CREATE TABLE public.tend_endereco ( 
cep varchar(10) NOT NULL, 
endereco varchar(200) NOT NULL, 
id_cidade integer NOT NULL, 
id_bairro integer NOT NULL 
) WITHOUT OIDS; 
-- 
-- Data for table public.tend_cidade (OID = 16940) (LIMIT 0,500) 
-- 
BEGIN; 

INSERT INTO tend_cidade (id_cidade, cidade, uf) 
VALUES (1, Acrelândia, AC); 

INSERT INTO tend_cidade (id_cidade, cidade, uf) 
VALUES (2, Assis Brasil, AC); 

INSERT INTO tend_cidade (id_cidade, cidade, uf) 
VALUES (3, Brasiléia, AC);
And it goes in many more lines, that I just don't know how many.

How can I import it to PostgreSQL?
I've tried it by the "CTRL+E" and OPEN, but it get stuck. Then I need to restart Postgresql.

If I manually insert this code into CTRL+E, it just doesn't work.
Is it because of this Script?

Anyone can please help me...I'm frustrated.

Thank you all,

Best,

Yuri Cavazin
--
GIS ANALIST
@ TECSA serviços LTDA
Reply With Quote
  #2 (permalink)  
Old 06-18-12, 11:29
arvindps arvindps is offline
Registered User
 
Join Date: Aug 2011
Posts: 40
I would suggest you break the query in parts, it is more practical and also helps bgworker jobs like logging,wal and constraints to be more precise.
Reply With Quote
  #3 (permalink)  
Old 06-18-12, 12:48
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,817
Quote:
When I try to import that SQL file to my PostgreSQL database I get stuck.
  1. In what way do you get stuck?
  2. Are any errors generated, and if so, what are the errors?
  3. Are you using SQL Manager for PostgreSQL to run the script on the target server? (If not, you should, since that was the app which created the script file. Theoretically, this shouldn't make a difference, but it might.)
  4. Are the source and target database servers at the same version level? If they are not, this could be the source of your problems: refer to the PostgreSQL release documentation for all pg upgrades between the two version levels.
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Reply With Quote
  #4 (permalink)  
Old 06-25-12, 12:47
ycavazin ycavazin is offline
Registered User
 
Join Date: Jun 2012
Posts: 2
PgAdmin III

Hi there,

I've found where the error was.

It was cuz my work-pc has lesser memory than recommended, and it got stuck.

I imported the SQL in a pc with more memory and it worked just fine.

Thank you all for the answers.

Best,

Yuri Cavazin
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On