We have a fixed length flat file which is stored in a table as a single column (say table name: flatfile1). We have another table (Metadata) where the file format is stored with start and end positions of each fields.
Now we want to write a select sql to separate the fields from table flatfile1 by reading the positions from table Metadata.
We have 50+ such flat files where we are trying to figure out a reusable approach to write the sql. Each of these files will have different number of fields with different length.
How could we go about this?
Related
I have an text file with a couple hundred records in it. I want to be able to join this information with another table. Currently, the only way I can think of is to create a table with CREATE and then use hundreds of INSERT INTO's (since INSERT INTO in Teradata doesn't support multiple insert values)
Is there a more efifcient way of achieving what I want?
Link the table in MS$Access, and paste the content of the text file directly into the Teradata table records. A rather fast method for small files, if you do it non-automated.
I'm using Oracle's DB.I have a table say T. It has following columns id, att1,att2,att3. Now for a large amount of data att3 is blank. I've created a csv file which contains data in the format id,att3 it has a lot of data. How do I updatefrom this file to existing rows?
Any way of doing it via pl/SQL
Which database engine are you using? The answer might vary depending on that.
But this post here How to update selected rows with values from a CSV file in Postgres? is similar to what you're asking, I'm sure you can adapt it to your needs.
I would like to use csv to describe a database schema. I found examples but for a single table, is there a standardized specification (or ideas, tracks etc.) for describing multiple (and linked) tables ?
CSV file only can have data with delimiter ( one line for one row and field separated with another delimiter)
So if you store data from different table in the same CSV, all data will be added to only one table.
best way is create different csv or choose another format ( why not sql ?)
One for the SQL data definition gurus:
I have a mainframe file that has about 35-100 different record types within it. Depending upon the type of record the layout and each column is redefined into whatever. Any column on any different record could become a different length or type. I am not really wanting to split this thing up into 35-100 different tables and relating them together. I did find out that postgres has %ROWTYPE with cursor or table based records. However in all examples the data looked the same. How can I setup a table that would handle this and what sql queries would be needed to return the data? Doesn't have to be postgres but that was the only thing I could find, that looked similar to my problem.
I would just make a table with all TEXT datatype fields at first. TEXT is variable, so it only takes up the space it needs, so it performs very well. From there, you may find it quicker to move the data into better formed tables, if certain data is better with a more specific data type.
It's easier to do it in this order, because bulk insert with COPY is very picky... so with TEXT you just worry about the number of columns and get it in there.
EDIT: I'm referring to Postgres with this answer. Not sure if you wanted another DB specific answer.
So I have some quite large denormalized tables that have multiple columns that contain comma separated values.
The CSV values vary in length from column to column. One table has 30 different columns that can contain CSV's! For reporting purpose I need to do a count on the CSV values for each column (essentially different types)
Having never done this before what is my best approach?
Create a new table using a CSV split method to populate and have a
type field and type table for the different types?
Use the XML approach using XPath and the .nodes() and .value()
methods to split each column on the fly and perform a count as I go
or should I create some views that would show me what I want.
Please advise