I have a script that parses xml file to generate SQLite table automatically. And, the simplified command is as follows.
Table string CREATE TABLE IF NOT EXISTS benchmark (id integer primary key autoincrement,Version float, CompilationParameters_Family text, CompilationParameters_XilinxVersion text, CompilationParameters_Device text, CompilationParameters_XilinxParameterList_Parameter_OptimizationGoal text, CompilationParameters_XilinxParameterList_Parameter_PlacerEffortLevel text)
It works well, but I wonder if I can attach some aliases for the long name in a database.
Is this possible? I mean, can I have a command something like
Table string ... CompilationParameters_XilinxVersion tex >>as version<< ...
so that I can use CompilationParameters_XilinxVersion or version when retrieve the data.
What you're trying to do is not possible in SQL. However, you may want to create a VIEW that simply substitutes the long column names with your short column aliases. Note that VIEWs in sqlite are read-only and therefore cannot be written to.
Related
So for my previous homework, we were asked to import a csv file with no columns names to impala, where we explicitly give the name and type of each column while creating the table. However, now we have a csv file but with column names given, in this case, do we still need to write down the name and type of it even it is provided in the data?
Yes, you still have to create an external table and define the column names and types. But you have to pass the following option right at the end of the create table statement
tblproperties ("skip.header.line.count"="1");
-- Once the table property is set, queries skip the specified number of lines
-- at the beginning of each text data file. Therefore, all the files in the table
-- should follow the same convention for header lines.
I had a table named XXXX. Suddenly, my table's contents were dropped (DROP table). I want to recreate my table, I know the schema of my table and I am having a text file with contents of my table before dropped.
Can I recreate my table without insert each row because it would take
a long time?
Is there any easy way to transfer the contents of text file to table
independent of the query language?
I'm using (MSSQL,POSTGRESQL,etc...)?
On PotsgreSQL
Procedure will be :
CREATE TABLE tablename (your fields);
Then admit your file is with good fields separators. The default is a tab character in text format, a comma in CSV format, do :
COPY tablename FROM 'path-to-your-file/filename.txt' WITH DELIMITER ',';
The path to your file should be accessible by the PostgreSQL server to /tmp is usually the more simple way to put your file.
Then you get back your table.
So I got the command for adding a comment/field definition for a column of a Hive table. I believe the following statement (maybe with slight modifications) does the purpose:
alter table abc CHANGE x x bigint [COMMENT "hello"];
However, I wish to add a "hyperlink" comment instead of just text so that I can show the field definitions over a web interface
Is there a way to do this?
I have a csv file with more than 100 columns and I want to create a table in oracle with the similar structure, then populate it.
Do you have any idea how to do this ? ( SQL*Loader, External tables, ..)
I don't want to use the classic " Create table " and specify for each column the name and type.
It's a workaround, but does it work:
If you don't want to specify column names, you can import you CSV in Access.
Then, after you have defined a DSN, you can export your table to Oracle.
I have Access as my back end. Student is the database name and its path is c:\Project\student.mdb
And am having few tables in it. When i click a command button in vb.net a new table must be created in the path mentioned. And it should have the fields I declare.
What s the query I need to use ? Is it possible to do like that ?
Yes, it's possible, you can check out the syntax for the create table command.
However, I have to say that creating tables dynamically suggests a bad database design. The database layout should normally remain the same whatever data you put in the database.
If you create tables dynamically, that means that you have data in the table names, but data should go inside the tables, not in table names (or even field names).
Yes it's possible . Just pass the create table command as query and the table name as variable , which you want to add dynamically. for reference of create table command
Create table command