How to store files on mysql server - sql

I need to send files like an image or pdf to a mysql database from a vb.NET form. How can i do this? is there a specific column type? what type of sql query should i write to send the file?

You can upload and save file in a folder in the server, and the filename or path of the file in the database along with an unique identifier.
If you really want to save the file in database (which is highly not recommended) you can use blob datatype. but it is mostly recommended to save the file pathname in the database column as a string, while you store the file to a local storage, and when you need to display the file, you just get the path saved in your database column, this should give you the file.

Related

how to read a tab delimited .txt file and insert into oracle table

I want to read a tab delimited file using PLSQL and insert the file data into a table.
Everyday new file will be generated.
I am not sure if external table will help here because filename will be changed based on date.
Filename: SPRReadResponse_YYYYMMDD.txt
Below is the sample file data.
Option that works on your own PC is to use SQL*Loader. As file name changes every day, you'd use your operating system's batch script (on MS Windows, these are .BAT files) to pass a different name while calling sqlldr (and the control file).
External table requires you to have access to the database server and have (at least) read privilege on its directory which contains those .TXT files. Unless you're a DBA, you'll have to talk to them to provide environment. As of changing file name, you could use alter table ... location which is rather inconvenient.
If you want to have control over it, use UTL_FILE; yes, you still need to have access to that directory on the database server, but - writing a PL/SQL script, you can modify whatever you want, including file name.
Or, a simpler option, first rename input file to SPRReadResponse.txt, then load it and save yourself of all that trouble.

Capture Multiple File Names into a column on SSIS

Hope you can help me.
I am looking to retrieve multiple file-names into a column from files I wish to upload onto SQL in a custom column on SSIS.
I am aware of using Advanced Editor on the Flat File Source in Component Properties > FileNameColumnName. However, I am not sure how to make sure it picks up all the file names or what to enter in this field?
I can upload the files and all the data it holds but not the filename into a column.

Use SQL to create a text file and save to a varbinary blob file without writing to disk

I currently have a working SQL stored procedure that is using BCP and xp_cmdshell to create a text file on the system disk and then upload that file into a varbinary field in an Attachments table.
What I'm needing to know is if it is possible to do this without writing a file to disk as part of the process?
UPDATED DETAILS
I am using MSSQL 2014 and the intention is to load the text file (a csv file actually) into the database so that other users can download it.
Is Text File is generating only for pusing content into varbinary fields?if so why dont you use simply convert the content directly into varbinary using convert function and push directly the results into table field.
If i am getting wrong correct me pls.

how to read data stored in blobs

my application datbase in postgressql and from the document i understand that it store few data in a blob and from the table i can only get the oid of it.
is there any possibility to read the content from these blobs? if yes, could someone share the knowhow?
From the OID, a file with the contents of the large object can be exported.
Either client-side (psql):
\lo_export oid-to-export /path/to/a/file
Or server-side in SQL (creates the file on the server, beware that postgres must have the permission to write into the destination directory).
SELECT lo_export(oid-to-export, '/path/to/a/file');

loading fileS into a field of a BLOB type. PL SQL

The task is:
Load all files from a specified directory into a table, into a field
of a BLOB type
What confuses me is that all files are to be written into one BLOB field.
Is it possible to do in a meaningful way, so that we could read separate files from the BLOB field later?
What comes to my mind is to use some sort of a separator character between each file when writing to a blob.
Little help?
One way can be to save each file in separate blob, each in it's own line (having same DIRECTORY_ID):
M_DIRECTORY FILE_NAME FILE_CONTENT(blob)
1 abc.txt [content of the file]
1 a.zip [content of the file]
Another option if you are really really sure you will never change data, you can store it in one BLOB, zipped content of this directory.
If have a doubt, choose 1st option.