Will come directly to the question.
Have 2 parameter like filename and table name. The requirement is to upload the data from the excel sheet to the database table enter in the other parameter. This should be in run time. No hardcoding of field names and that program should be flexible enough to suite any table. Please help.
I can think of two possible approaches:
Dynamic code generation -- write a program which writes a program
Use dynamic type tools
For 1. try googling
For 2. see https://wiki.scn.sap.com/wiki/display/Snippets/Example+-+create+a+dynamic+internal+table - this wiki shows a way (not sure if it is overkill as it creates the type from scratch whereas any table in your SAP system is already a defined type in the Data Dictionary).
You can do easily reference a parameterised table in Open SQL e.g. MODIFY (p_tab) ...
Perhaps you could do a generic SPLIT of a line read in from file by the delimiter into a table of fields - you can then use ASSIGN COMPONENT to match the fields you have read in to the fields in your internal type.
If you are doing this I think a white list of allowed tables would be wise - and auth checks. Otherwise someone could upload SAP standard tables with no authorisation.
I have a txt file containing a table with two columns student ID and GPA. I want to create a similar table in Oracle SQL developer. Is there some way to copy this data directly into SQL developer
If you are looking for a simple GUI method, you can connect to a db, right click on "Tables", "import data..." and use the Data Import Wizard.
Select the correct options (csv/delimited, tableName, cloumnsToImport...) and click "Finish".
Sorry, I cant post pics yet see the example screenshot here: http://i.stack.imgur.com/S7HFx.png
You can create external table with that file, then copy the external table into a new internal table (usual table), here is a full example:
External Tables Concepts
Then go to:
Example: Creating and Loading an External Table Using ORACLE_LOADER
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Using a script (however without using data import/export, without using backup restore, without using database copy) how can I copy complete tables (schema and data) from one database on the same server to another database on the same server?
I've already tried to do what I've italicized above; however, due to user permissions etc, I was unable to use those methods.
Perhaps this will work:
SELECT *
INTO newdb.dbo.newtable
FROM olddb.dbo.oldtable
But I would like to apply this to every table (around 100 tables).
If you're truly a sysadmin, I don't understand what's wrong with backup and restore.
BACKUP DATABASE <DatabaseName, sysname, DatabaseName>
TO DISK=N'<backup_location, varchar, BackupLocation>.bak'
WITH INIT, FORMAT, COMPRESSION, COPY_ONLY
RESTORE DATABASE <NewDatabaseName, sysname, NewDatabaseName>
FROM DISK = N'<backup_location, varchar, BackupLocation>\
<DatabaseName, sysname, DatabaseName>.bak'
WITH
MOVE '<DataFileName, sysname, DataFileName>' TO '<DataMDFPath, nvarchar(600), DataMDFPath>',
MOVE '<LogFilePath, sysname, LogFilePath>' TO '<LogLDFPath, nvarchar(600), LogLDFPath>',
REPLACE;
Here, see, I even templated it for you.
If you have SSMS, you can right-click the database and select "Script Database As" -> "Create To". This will generate DDL scripts for all the objects you want (tables, indices, views, etc)
After you run those, use:
SELECT 'INSERT newdb..'+name+' SELECT * FROM olddb..'+name FROM sys.tables
To generate the copy commands. If you have computed columns, you'll need to join the sys.columns table to filter those out. If you have multiple schemas, you'll need to specify them. You'll also need to sort these DML commands based on your foreign key hierarchy. With only 100 tables, it's feasible to do that manually.
Are you using Microsoft SQL Server Management Studio? If so...
You can use the Script Table As... Option and select the New Query Editor Form under the CREATE TO option.
From there you should just be able to change either the Table Name, or the targeted Database.
In conjunction with this you can use the information found here: https://stackoverflow.com/a/7515236/2543917 in order to move over your data.
If you need some more actual code examples then let me know and I can provide.
This question already has answers here:
Procedure to export table to multiple csv files
(2 answers)
Closed 9 years ago.
please help me to create a procedure to export data to specified path from oracle database as .csv file take study names from another table.
QUERY : select * from enrollment where study_name = 'FTY67' ;
I have another table(studies) in same database with all studynames.
is there any way to create procedure that will take study names from studies table and repeat this procedure to create .csv files for all studies?
read some articles in internet but not found anything related to this.
please help.
You should look into the spool and set command. Since the database is usually running on a remote server, it can not write files to your local computer. In order to achieve this yu must write an sql where you disable certain characteristics in the terminal, and then spool the result into a file that you can access.
Something like this might get you started:
set term off colsep ";" pause off
spool myfile
select * from x;
spool off
exit
For an overview of the options you can use with SET refer to the oracle documentation here: http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12040.htm
With the proper set commands you are able to create the CSV file.
The above set commands are just a few you might need, but you will probably need addtional parameters to make your CSV usable.
Best to write this in a file.sql and run it using sqlplus:
sqlplus user#db #file
I want to create update script for BLOB column in Table which stores XSL Data in ORACLE. Can anybody help me in simple way without creating any directory. Here number of character involved is also more than 4000.
I have modified in TOAD by 'Save to File' and again from 'Load to File'. Now I want to transfer it to some other database using SQL Script.
Using the Oracle IMP and EXP utilities you can export a table into a file and import it into another database. Here is some information on how to use them:
http://www.orafaq.com/wiki/Import_Export_FAQ
It is not SQL but it also doesn't involve creating directories.