Enclosed by " while generating a file from a table

Moderator: NorbertKrupa

Post Reply
rajasekhart
Intermediate
Intermediate
Posts: 87
Joined: Wed Apr 25, 2012 8:10 am

Enclosed by " while generating a file from a table

Post by rajasekhart » Mon May 07, 2012 8:19 am

Hi,

I want enclose the data within double quotes (") ,While i am generating a file from a table.

Eg: Create table Employee(Emp_Id int, Emp_Name varchar(80) )

Insert into Employee
select 1, 'Raj' union all
select 2, 'Smith' union all
select 3, 'Rose';

select * from Employee;
Emp_Id Emp_Name

1 Raj
2 Smith
3 Rose


Now i want to generate a file to this table , and i want the data in the file enclosed by double quote (") as follows.

Raj=> \o /home/dbadmin/Employee --file name Employee
Raj=> select * from Employee

Emp_ID Emp_Name
"1" "Raj"
"2" "Smith"
"3" "Rose"

Please help me

Thanks in advance ,
Raj
Rajasekhar.T|HP ATP Vertica Big Data Solutions V1

id10t
GURU
GURU
Posts: 732
Joined: Mon Apr 16, 2012 2:44 pm

Re: Enclosed by " while generating a file from a table

Post by id10t » Mon May 07, 2012 1:08 pm

Hi Raj

Code: Select all

%> vsql -c "select * from encloseExample;"
  a  | b |  c  
-----+---+-----
 111 | b | baz
 333 | d | egg
 666 | a | foo
 999 | c | bar
(4 rows)

Code: Select all

%> vsql -At -F '" "' -c "select * from encloseExample;" | sed -e 's/^\|$/"/g'
"111" "b" "baz"
"333" "d" "egg"
"666" "a" "foo"
"999" "c" "bar"

Post Reply

Return to “Vertica Database Development”