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
Enclosed by " while generating a file from a table
Moderator: NorbertKrupa
-
- Intermediate
- Posts: 87
- Joined: Wed Apr 25, 2012 8:10 am
Enclosed by " while generating a file from a table
Rajasekhar.T|HP ATP Vertica Big Data Solutions V1
Re: Enclosed by " while generating a file from a table
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"