Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Select .. Into Outfile Write


global scope:
trying to execute on a schedule a .sql file which writes out
a .csv file.

windows(dont ask)/mysql

in the batch file i have

mysql -u myUser --password=somePass < myFile.sql

the sql query in the file

Code:

use mydb;
select field1,field2,field3
union
select `actField1`,`actField2`,`actField3` into outfile 'F:folder est.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM `detailsTable`;




View Complete Forum Thread with Replies

Related Forum Messages:
MySql OUTFILE, ERROR 1 (HY000): Can't Create/write To File
I have problems in exporting tables to a file in MySql using OUTFILE option. MySql machine is a remote one. I got the error

ERROR 1 (HY000): Can't create/write to file '/tmp/scshekaran/bcp_table.txt' (Err 2)

View Replies !
Select * Into Outfile
im trying to execute this sql statement

select * into outfile '/tmp/numbers.txt' from tableName where thisField like '%this%'

the statement executes with no errors, but the text file is not created.

when i create a file of the same name on the server, and execute, an error kicks up saying 'the file already exists'
what do you think is happening here, why is the txt file not being created?

View Replies !
Select Into Outfile
I'm using the comand select * into outfile. It´s working and I get a .txt-file. My problm is, that I need the headers of the columns and right now they are not included. Is there a comand, what tells Mysql to write them in the text-file? MySQL-version is 4.0.

View Replies !
SELECT ... INTO OUTFILE
I have a quick question about using the SELECT ... INTO OUTFILE command.

Whenever I try to export some rows to a text file (e.g. XYZ.csv) that already exists on the destination folder, I get an error message saying "File XYZ.csv already exists".

Is there any option in the SELECT .... INTO OUTFILE syntax that allows me to overwrite the file I'm trying to create?

I've searched for answers and tried to play around with IGNORE or REPLACE, but could not make it work. Here is a simple example of what I'd like to do: ....

View Replies !
Select Into Outfile
I'm using the following command to export data:

SELECT * FROM Agents INTO OUTFILE '/tmp/agentsUpload4.txt' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '';

But I have N and little squares(ASCII null bytes?)in the output where the tables contain nulls.
How can I tell mySQL to output these as ''(empty string) instead?

View Replies !
Variables In Select Into Outfile
I wan to use a variable for the outfile file name in a select into clause. I am
doing something like:

set @fileName="/tmp/result.text"
SELECT col1, col2 INTO OUTFILE @fileName
FIELDS TERMINATED BY ','
FROM test_table;

the interpreter dies at the @fileName...
if I exchange @filename with "/tmp/result.text" it runs fine.



View Replies !
Select Data Into Outfile
Thought I'd post that info here in case someone was looking for it.

Guelphdad - I found this thread:
http://lists.mysql.com/mysql/163185
I understand you may get what you want using batch mode.

Now I ran it directly from my command prompt and saved the file in the current directory (on WinXP, sure the same works for Linux)

echo SELECT * from animal | mysql -udavemysql -p***** testdb > mysqloutfile.txt

I found I had to name the database i was using or of course got the no db selected error message.

View Replies !
SELECT ... INTO OUTFILE Options
how to use the SELECT ... INTO OUTFILE command to create a csv file of query output. The problem i have is that the resulting file doesnot have column headers. Is there an option that i need to turn on/off to enable the output file have column headers.

View Replies !
SELECT INTO OUTFILE 'filename'
Im trying to create a stored procedure in mysql 5 to dump the result of a select statement into a file. When i give the actual file name, it works perfectly.

I want to give the filename as a variable that is parsed into the procedure, how do I do this.

This is the procedure i used, and it works...

CREATE PROCEDURE `genfile`()
BEGIN
SELECT * FROM vreg INTO OUTFILE 'TEST.TXT';
END

Please tel me how i can parse a filename as a parameter and use it as the filename.
When I do the below, i get an error,

CREATE PROCEDURE genfile(IN filename VARCHAR(100))
BEGIN
SELECT * FROM vreg INTO OUTFILE filename;
END

View Replies !
Select ... Outfile ... Fixed Length?
I have query that I export into a file using the "outfile" syntax. I can
use the following lines of code to create a delimited file but I want to
know if I can create a fixed length file? Any ideas?

delimited file:
Select GivenName, Surname, Address, City, State, ZipCode
into outfile 'xx.csv' fields terminated by ',' lines terminated by '
'
from kbm
where zipcode = '12345'

View Replies !
Select Into Outfile With Field Descriptions?
Is there a way to have the field descriptions put into an outfile? When I do a Select * from data, the display shows the field names, however when I do the select * into outfile /tmp/test.txt the field names are not in the file.

View Replies !
Running SELECT INTO OUTFILE As A CRON Job
I need to run the "SELECT * INTO OUTFILE" command as a CRON job. I can do this via command line and it works fine, but when I add it to my CRON file it does not run.

My problem is I dont know how to create a CRON job or script that logs into mySQL and then runs the "SELECT * INTO OUTFILE" command.

I am currently running "mySQL DUMP" as a CRON job without any problem.

View Replies !
SELECT INTO OUTFILE With Column Headers
I've just written a stored procedure that uses the SELECT INTO OUTFILE command. I'd like the file it writes to contain the column headers similar to the way that they show up from a command line call.

View Replies !
Select Into Outfile Sort Data
i have the following query :

(used in visual basic)

"select * into outfile ......where id=irand || id=irand2 || id=irand3 || id=irand4 || id=irand5 "

the problem is that in the file created the data in sorted ASC, i need the data to output like in the query, irand,irand2,irand3,irand4 and irand5,

i see order by 1,2,3,4,5 as a solution but it didnt worked.

View Replies !
SELECT INTO OUTFILE Access Denied
I am trying to make a big text file from an old forum version I use on my virtual LAMP server.

For this I am using the following statement:

SELECT threads INTO OUTFILE '/home/me/threads.txt' FROM forums;

I get the following error:

ERROR 1045 (28000): Access denied for user 'me'@'ip-adres' (using password: YES)

It seems I don't have acces to write to a file via mysql. My ISP covered that perfectly, but is there a work arround?

If I do:

SELECT threads FROM forums;

All the threads scroll by on my terminal. But they are to big to fit in the terminal for a simple copy paste.........

View Replies !
SELECT INTO OUTFILE By Remote User
I was wondering if it were possible to make it so that if a REMOTE user connects to the server and issues a "SELECT INTO OUTFILE" type statement, the file created will be created locally on their machine rather than the server machine.

View Replies !
How To Write This Select?
I'm having some troubles writing a select. I have the following tables:

theater
-------
- id
- name

movie
-----
- id
- name

showtime
---------
- id
- theater
- movie
- from
- to
- schedule

I would like to list all the theaters with all the available showtimes and movies. I tried to, but i didn't get the result i was expecting. Can somebody help?


View Replies !
SELECT INTO OUTFILE :: Include Column Names
I have data in a table that I would like to select into an outfile. I can do this no problem but the problems lies with the fact I would also like to include the column names and if possible overwrite the file if it already exists.do you know if either of these options is possible?

View Replies !
Deleting A File Created By SELECT INTO OUTFILE
I am running a shell script that has the msyql commands:

select "Data Load Complete" into outfile '/mysql/testfile.txt';

The textfile gets produced fine. My problem is I am not able to delete this file in the shell script because the owner is the mysql server. But I also don't know to delete the file directly via mysql.

View Replies !
Select ... Into Outfile Or Dumpfile Into Just One Text File
I want to transfer all newly inserted data into single text file. It means that every new insertion into the table will add a new line into the same text file. Is it possible to do that?

seems that i cant do it using select ..into outfile. Anyone have any idea how can i do it?

View Replies !
SELECT INTO OUTFILE - Unable To Find File
select <something> from <table> limit 5 into outfile '<path>'

The command executes without any error. But when I try to find the file at the saved location, I find nothing. If I re-run the the above query it returns error showing the file already exists! But still actually I don't see anything.

View Replies !
How To Write A SELECT/COUNT + Other Fields
I have a table like so:

NAME | AGE
Joey | 21
Mary | 18
Lass | 43
Moch | 33
Joey | 23
Mary | 25
Mary | 65
Lass | 90

I what to write a single query that retrieves the total number of times a single name is found in the the table (Joey appears two times, Mary appears 3 times, and Lass appears two times) AND also retrieves each record.

SELECT COUNT(name) as name_total, name, age FROM persons_table WHERE 1

RESULT:
row#: name_total, name, age:
row1: 2, Joey, 21
row2: 3, Mary, 18
row1: 2, Lass, 43
row1: 1, Moch, 33
row1: 2, Joey, 23
row1: 3, Mary, 25
row1: 3, Mary, 65
row1: 2, Lass, 90

View Replies !
Who Do I Write Select With Dates And Times
i have to cols, date and time. who can i do, SELECT between (date 1,time 1) to (date 2, time 2)?

for example i want to get the recordes between 2007-01-01 23:00:00 to 2007-01-03 03:00:00 ?

View Replies !
How To Write Query To Select The Max(version) For Each Unique File_name Record?
I am a MySQL newbie trying to write a query that selects file_name records
possessing the highest numbered version for that unique file_name. I show
sample data and two trial queries below. Logically I want to use
max(version) as a constraint in a Where Clause. However, the max() function
is not allowed directly in a where clause.

I have contemplated a second table to track the max version for each file
name. I would like to structure the data in an efficient manner for query
performance when the data set grows to many thousands of unique file_name
records with many hundreds of versions each........

View Replies !
ERROR 1022 (23000): Can't Write; Duplicate Key In Table On SELECT
I'm using the mysql server that comes with ubuntu-server 8.04 (mysql Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (i486) using readline 5.2) and I have a rather big database (about 5M records).

If I try to do this
mysql> select count(*),lastname from data group by lastname;

all i get is the following error:
ERROR 1022 (23000): Can't write; duplicate key in table ''

The lastname column is the only one returning this error. (The statement works for firstname, city, street, etc...)

Does anybody have an idea as to what's happening here?

I've tried searching but could only find this error in relation to database updates and insertions (which would be logical considering the 'duplicate key' part).

View Replies !
Search And Write, Or Write And Recover?
The problem: I need to generate a 'unique string' for each row in a table. I already use auto_increment for system dependencies between tables.

What is the best approach one of these or another?

After generating a candidate 'unique string' the two strategies that came to mind are:

1. to then search the table's column to see if it is already assigned; locking the table for write while searching and writing the new row, or

2. set the column to UNIQUE when defining the table. Just go ahead and write the new row if you get a "non-unique" exception, generate another 'unique string' and try again.

I've tried both on a small XP laptop and get "lock timeout exceptions" rather quickly using #1. But replace those with lots of re-writes when there starts to get "collisions" of 'unique string's.

View Replies !
"select Into Outfile " Issue
I am running MYSQL 5.0 ON WINXP pro.

I have the following procedure:

View Replies !
Into Outfile
I am using MySQL v4.1.20. I need to output records to a file the customer can then open with MS Excel. I could not get the PHP script to create this file so I went to PHPMyAdmin to craft the query.

Here is what I am trying:

SELECT *
INTO OUTFILE 'd:siteshansenplus.csv'
FIELDS ESCAPED BY ''
ENCLOSED BY '"'
TERMINATED BY ','
FROM plusservices;

There are records in the table. The query runs but returns a null data set and no file is created.

I have tried many variations on the SQL syntax. This version is the only one that will run.

View Replies !
Outfile
Tried to write data from a query out to a file and get told permission denied if I use any directory paths - unix. If I jsut put a name.txt, it exports, but I can't find the file anywhere, yet if I re-export, I'm told the file already exists.
What am I missing?

View Replies !
Add Headers To Outfile
I'm selecting records into an OUTFILE;

SELECT foo,bar INTO OUTFILE '/tmp/foo' FIELDS TERMINATED BY ',' FROM bar

I would like to add the headers foo and bar to the output file. How can I have mysql do that automatically.

View Replies !
Outfile Of Sql Data
Here the SQL Statement:
mysql> select c.company_id, c.name from company c, co_directory d where c.company_id=d.company_id and d.directory_id=10 into outfile "comp_dir10.txt";
I have executed the above statement in my mysql server. Where the output file will stored. ?

View Replies !
Into Outfile In Client PC
I'm Using Mysql V3.22+ And Im Trying This Query Select ... Into Outfile... In the Mysql Control Center But It Cant Work! Does Any 1 Can Tell Me How To Write The Data In The Database Into A File In Client Pc

View Replies !
Syntax For Outfile
I'm a kinda newbie at MySQL...
I can't seem to gather where my typo is for running a query for outfile into a file. I get confused to what's going on when I do see that it created a file name "Datalist.txt" in the c: drive but its filesize is 0kb -an empty file...What to do??

SELECT TABLE2.file1
lines terminated by '
'
FROM TABLE1, TABLE2
where (TABLE2.TABLE2_id=TABLE1.TABLE2_id) and (TABLE2.file='OutPutFile.txt') limit 100;

View Replies !
Outfile Permissions
I tried to write a query out to a file, but I got this message:

ERROR 1 (HY000): Can't create/write to file '/home/jason/test.csv' (Errcode: 13)

How can I set mysql to allow those permissions to write anywhere I want?

When I don't specify the directory, the command works,

View Replies !
Remote OUTFILE
I have three servers (S01,S02,S03)... my aplication PHP run in S01 and there are two databases in S02 and S03.

I make one file and I'm using LOAD DATA LOCAL INFILE INTO tbl_xxx to load file in S01 to S02.

My problem is:

I need export data from S03 to S01 using only mysql.
I'm using SELECT OUTFILE, but this statment is only local.

is it possible?

View Replies !
OUTFILE To Blob
i wonder if this is possible:

1) I would like to create a backup of data from a trigger - this backup should load all data regarding a user (from various tables) into blob columns in a other table

now - i know one can use outfile ...... and then load it back into a blob - however , my problem is that i will be using mysql on a shared hosting platform ... writing to file wil not be permitted... i will have to insert the blob directly from a varaible or a select query..

View Replies !
INTO OUTFILE Permission
I have the MySQL server on a shared file server, and would like the internal network users to query the database and store the results in text or Excel format on their local drives (Or a mapped shared drive).

Currently in the test version of this system,i have Mysql running on local host and the scripts on the same system. All the files are traded locally under test.
But when i try to save the generated excel files to a shared location i get an error.

View Replies !
Dump Data Outfile
is there a way to dump just data to a file similar to the way "load data
infile" reads data?

View Replies !
Outfile Name As Parameter In Proc
can I use the outfile_name as a parameter for my proc?

DELIMITER $$

DROP PROCEDURE IF EXISTS `shema`.`sp_name` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_name`(in outfile_name varchar(100))
BEGIN

SELECT * FROM manufacturers
limit 11
INTO OUTFILE outfile_name
FIELDS TERMINATED BY ' '
LINES TERMINATED BY '
' ;

END $$

DELIMITER ;

I get an error

please correct my e-mail address to Robertsmargalit@yahoo.com

View Replies !
Dynamically Change Outfile Name
I've tried many things, but I just can't seem to solve this...
Here's what I want to do: I'm going through some data with a cursor and I want to take each row that the cursor fetches into a separate file. To achieve this, I have to dynamically change the file name, but I can't seem to be able to do it, although I tried several solutions.

Here's my code at the moment:

CREATE PROCEDURE curdemo()
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE inc INT DEFAULT 1;
DECLARE a,b TEXT;
DECLARE cur1 CURSOR FOR SELECT CONCAT(book_description, book_extended) FROM bookmark;

DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

OPEN cur1;

REPEAT
FETCH cur1 INTO a;
IF NOT done THEN
SELECT CONCAT('d:/tmp/result', inc, '.txt') INTO b;
SELECT a INTO OUTFILE b;
SET inc=inc+1;
END IF;
UNTIL done END REPEAT;

CLOSE cur1;
END;

View Replies !
Using Variable In OUTFILE Path
I am atmysqlting to create an XML text file for selected records using the following (simplified) code. The SQL statement produces the desired result as long as I leave off the INTO OUTFILE portion. And it works if I set the file name to a string i.e. ‘filename.xml’ and only send one record.

However when I try to create multiple files by adding a variable filename, I get an error message:
Unknown column 'AssemNum' in 'field list'

CREATE PROCEDURE WriteFile(In StartID Int, EndID Int)
BEGIN
Declare Path text default 'C:/mysql/ ';
WHILE StartID <= EndID DO
Begin
set @xsql = concat("select AssemNum, mySQLStatement
from AssemData where AssemID = StartID;
INTO OUTFILE '",concat(Path,AssemNum,'.xml'),"'
LINES TERMINATED BY '
'");
PREPARE stmt from @xsql;
EXECUTE stmt;
SET StartID = StartID + 1;
END;
END WHILE;
END

View Replies !
Is It Possible Outfile Without Null Fields?
I would like my end oufile to not have /N or NULL in fields that are null or to have a query that would filter out all the null fields before exporting.

View Replies !
Korean File Name For Outfile
select * into outfile 'filename' from table;

When I supply a korean/japanese file name in place of 'filename' in the above query, file is getting generated but with non readable krean/japanese file names.

I am running MySQL 4.1.12 with multi lingual support. utf8 as default character set in both client and server.

View Replies !
Is It Possible To Use INTO OUTFILE To Amend A File?
I'm using multiple SELECT ... INTO OUTFILE commands to write the results to seperate text files at the moment. Would prefer if the results of each statement were written to the same file (with each statement amending, rather than replacing the file contents). Is this possible?

View Replies !
Syntax Error Using INTO OUTFILE Without FROM
This works:

SELECT "x" INTO OUTFILE "/path/xxx" FROM table-name;

This fails with a syntax error:

SELECT "x" INTO OUTFILE "/path/xxx";

Shouldn't this work?

I want to use this syntax in a UNION to add a constant value row to the results of the first SELECT, and the final SELECT is the one that has to have the INTO OUTFILE. No FROM is required, but the syntax fails.

Is there some requirement for FROM with INTO OUTFILE? Or is this a bug?

View Replies !
Accent Problem With Outfile Command
I'm using mysql 4.1.
When I insert data with special french character with accent é, à...
and that I use select command to see the line, I can see the
characters correctly.
But when I use the outfile command the characters are not in the
correct format.

I tried several charset and collation, but it seems that it's not the
problem.

View Replies !
How To Get MY SQL Query Messages Into A Single Outfile
I want to run set of queries and want to get the messages after executing them into one outfile.

e.g when I run query "Select * from accounts", when the query is successfully executed, it gives message "1000 rows in set (0.01) sec".

I want to get all such messages from different query sets into one outfile.

Can anybody guide me on how to get the same?

View Replies !
MySQL Outfile Escaping Characters
SELECT people_id, people_fname, people_sname FROM people WHERE people_id IN (1, 2, 3) INTO OUTFILE '/home/test.csv' FIELDS ESCAPED BY '' OPTIONALLY ENCLOSED BY '"' FIELDS TERMINATED BY ',' LINES TERMINATED BY '
'
When executing this statement in SQL Yog i get this error...

Error Code : 1064
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'FIELDS TERMINATED BY ',' LINES TERMINATED BY '
'' at line 1

This is being used for a java service to export results to a csv file. I honestly can't see what is wrong with this. I want to use a backslash to escape chars that need escaping and a double quote to enclose fields. Both of those characters for the query need to be escaped i would think.

View Replies !
How Can I Print The Results Of A Consult Into An Outfile?
I've been trying to print the results of my consults to the database I created. Although I've seen that the query it's OK, I can't find the file where are my results. Do you know how can I print my results to one outfile or where I could find it?

View Replies !
Deleting Files Created By INTO OUTFILE
I created output files using the INTO OUTFILE. I redirected the files to be stored in my local drive. But when I try to delete these files if returns an error :

Cannot delete test: Access is denied.
Make sure the disk is not full or write-protected and that the file is not currently in use.

I do have the permission to delete or modify the files. I can delete any other document within the same drive. I even reboot the computer and tried deleting but it just does not want to be deleted.

FYI, these files are in the .dat and .txt format.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved