How to get the insert scripts from a table data
hi all,
i want insert scripts for 100 records from a table.
suppose i have a table xyz
xyz:
id name
1 abc
2 def
i should get insert script for 100 rows like
insert into xyz(id,name) values (1,'abc');
insert into xyz(id,name) values (2,'def');
i want 100 records data from all the tables from my database.
thanks in advance to all.
SQL> create table xyz (id number, name varchar2(10));
Table created.
SQL> insert into xyz values(1,'abc');
1 row created.
SQL> insert into xyz values(2,'def');
1 row created.
SQL> select 'insert into xyz values(id,name) values('||id||','''||name||''');' from xyz;
'INSERTINTOXYZVALUES(ID,NAM
insert into xyz values(id,name) values(1,'abc');
insert into xyz values(id,name) values(2,'def');
SQL>- - - - - - - - - - - - - - - - - - - - -
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com
[Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]
Similar Messages
-
How to get the row difference from two tables
I am not good at SQL. Here is a problem I am having
I have two tables say Employee_Master and Employee_Today. Employee_Today table is basically a subset of Empolyee_Master. At a given time, I want to query the database and and get all the employee names from Employee_Master table that are NOT in the Employees_Today table. How would I write that?
Select a.name from Employee_Master a, Employee_Today b where ..........?
Thanks for suggstionsif i understand your requirement correctly try this:
Select a.name from Employee_Master a
Where Not Exists
(Select 'x' From Employee_Today b
Where b.name = a.name) ;hope this helps -
How to get the Runtime ID from Audit tables?
Hi,
I have a process flow which contains two processes. Each process has 20 mappings. after the process executes correctly, I need to pick up OWB runtime ID and store it in my own audit table. How to implement this?
Regards
Kishan.Hello,
this link is the solution to your problem: Capture RUN_ID when executing a mapping
Export the sample mapping in this link and import it in your OWB.
Regards
Franz -
How to get the row count of a Table DATA?
Hi,
In my Adobe form layout, I have a Table node which is bound to an internal table. Now at runtime, I want to determine the number of rows that the internal table has, i.e the row count of the DATA node of the Table. How will I be able to determine the no. of rows of the internal table at runtime using Javascript? I am not being able to find any suitable answer in this forum. Please suggest. Thanks in advance.Hi,
If you bind the interactive form table to the internal table and specify some properties, the table will vary its row size according to the number of data available in the internal table.
You have to wrap the table in a sub form, check 'allow page break with contents' and property 'flowed'.
the table will automatically increase its row size...
Is this the reason for which you wanted for the row count..?
If so, this will help you..
Regards.
Surya -
How to generate the insert script of the tables data present in an entire
How to generate the insert script of the tables data present in an entire schema in sqlplus environment
with out toad can you please help me please!!!!!!!!!!!!!HI,
First create this function to get insert scripts.
/* Formatted on 2012/01/16 10:41 (Formatter Plus v4.8.8) */
CREATE OR REPLACE FUNCTION extractdata (v_table_name VARCHAR2)
RETURN VARCHAR2
AS
b_found BOOLEAN := FALSE;
v_tempa VARCHAR2 (8000);
v_tempb VARCHAR2 (8000);
v_tempc VARCHAR2 (255);
BEGIN
FOR tab_rec IN (SELECT table_name
FROM user_tables
WHERE table_name = UPPER (v_table_name))
LOOP
b_found := TRUE;
v_tempa := 'select ''insert into ' || tab_rec.table_name || ' (';
FOR col_rec IN (SELECT *
FROM user_tab_columns
WHERE table_name = tab_rec.table_name
ORDER BY column_id)
LOOP
IF col_rec.column_id = 1
THEN
v_tempa := v_tempa || '''||chr(10)||''';
ELSE
v_tempa := v_tempa || ',''||chr(10)||''';
v_tempb := v_tempb || ',''||chr(10)||''';
END IF;
v_tempa := v_tempa || col_rec.column_name;
IF INSTR (col_rec.data_type, 'CHAR') > 0
THEN
v_tempc := '''''''''||' || col_rec.column_name || '||''''''''';
ELSIF INSTR (col_rec.data_type, 'DATE') > 0
THEN
v_tempc :=
'''to_date(''''''||to_char('
|| col_rec.column_name
|| ',''mm/dd/yyyy hh24:mi'')||'''''',''''mm/dd/yyyy hh24:mi'''')''';
ELSE
v_tempc := col_rec.column_name;
END IF;
v_tempb :=
v_tempb
|| '''||decode('
|| col_rec.column_name
|| ',Null,''Null'','
|| v_tempc
|| ')||''';
END LOOP;
v_tempa :=
v_tempa
|| ') values ('
|| v_tempb
|| ');'' from '
|| tab_rec.table_name
|| ';';
END LOOP;
IF NOT b_found
THEN
v_tempa := '-- Table ' || v_table_name || ' not found';
ELSE
v_tempa := v_tempa || CHR (10) || 'select ''-- commit;'' from dual;';
END IF;
RETURN v_tempa;
END;
SET PAUSE OFF
SET LINESIZE 1200
SET PAGESIZE 100
SET TERMOUT OFF
SET HEAD OFF
SET FEED OFF
SET ECHO OFF
SET VERIFY OFF
SPOOL GET_INSERTS.SP REP
SELECT EXTRACTDATA('EMP') FROM DUAL;
SPOOL OFF
SET PAUSE ON
SET LINESIZE 120
SET PAGESIZE 14
SET TERMOUT ON
SET HEAD ON
SET FEED 5
SET ECHO ON
SET VERIFY ON
SELECT 'insert into EMP ('
|| CHR (10)
|| 'EMPNO,'
|| CHR (10)
|| 'ENAME,'
|| CHR (10)
|| 'JOB,'
|| CHR (10)
|| 'MGR,'
|| CHR (10)
|| 'HIREDATE,'
|| CHR (10)
|| 'SAL,'
|| CHR (10)
|| 'COMM,'
|| CHR (10)
|| 'DEPTNO) values ('
|| DECODE (empno, NULL, 'Null', empno)
|| ','
|| CHR (10)
|| ''
|| DECODE (ename, NULL, 'Null', '''' || ename || '''')
|| ','
|| CHR (10)
|| ''
|| DECODE (job, NULL, 'Null', '''' || job || '''')
|| ','
|| CHR (10)
|| ''
|| DECODE (mgr, NULL, 'Null', mgr)
|| ','
|| CHR (10)
|| ''
|| DECODE (hiredate,
NULL, 'Null',
'to_date('''
|| TO_CHAR (hiredate, 'mm/dd/yyyy hh24:mi')
|| ''',''mm/dd/yyyy hh24:mi'')'
|| ','
|| CHR (10)
|| ''
|| DECODE (sal, NULL, 'Null', sal)
|| ','
|| CHR (10)
|| ''
|| DECODE (comm, NULL, 'Null', comm)
|| ','
|| CHR (10)
|| ''
|| DECODE (deptno, NULL, 'Null', deptno)
|| ');'
FROM emp;
SELECT '-- commit;'
FROM DUAL;now run the baove select statement you will get the following insert statements
/* Formatted on 2012/01/16 10:57 (Formatter Plus v4.8.8) */
--'INSERT INTO EMP('||CHR(10)||'EMPNO,'||CHR(10)||'ENAME,'||CHR(10)||'JOB,'||CHR(10)||'MGR,'||CHR(10)||'HIREDATE,'||CHR(10)||'SAL,'||CHR(10)||'COMM,'||CHR(10)||'DEPTNO)VALUES('||DECODE(EMPNO,NULL,'NULL',EMPNO)||','||CHR(10)||''||DECODE(ENAME,NULL,'NULL',''''|
INSERT INTO emp
(empno, ename, job, mgr,
hiredate, sal, comm, deptno
VALUES (7369, 'SMITH', 'CLERK', 7902,
TO_DATE ('12/17/1980 00:00', 'mm/dd/yyyy hh24:mi'), 800, NULL, 20
INSERT INTO emp
(empno, ename, job, mgr,
hiredate, sal, comm, deptno
VALUES (7499, 'ALLEN', 'SALESMAN', 7698,
TO_DATE ('02/20/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1600, 300, 30
INSERT INTO emp
(empno, ename, job, mgr,
hiredate, sal, comm, deptno
VALUES (7521, 'WARD', 'SALESMAN', 7698,
TO_DATE ('02/22/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1250, 500, 30
INSERT INTO emp
(empno, ename, job, mgr,
hiredate, sal, comm,
deptno
VALUES (7566, 'JONES', 'MANAGER', 7839,
TO_DATE ('04/02/1981 00:00', 'mm/dd/yyyy hh24:mi'), 2975, NULL,
20
INSERT INTO emp
(empno, ename, job, mgr,
hiredate, sal, comm,
deptno
VALUES (7654, 'MARTIN', 'SALESMAN', 7698,
TO_DATE ('09/28/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1250, 1400,
30
INSERT INTO emp
(empno, ename, job, mgr,
hiredate, sal, comm,
deptno
VALUES (7698, 'BLAKE', 'MANAGER', 7839,
TO_DATE ('05/01/1981 00:00', 'mm/dd/yyyy hh24:mi'), 2850, NULL,
30
INSERT INTO emp
(empno, ename, job, mgr,
hiredate, sal, comm,
deptno
VALUES (7782, 'CLARK', 'MANAGER', 7839,
TO_DATE ('06/09/1981 00:00', 'mm/dd/yyyy hh24:mi'), 2450, NULL,
10
INSERT INTO emp
(empno, ename, job, mgr,
hiredate, sal, comm,
deptno
VALUES (7788, 'SCOTT', 'ANALYST', 7566,
TO_DATE ('04/19/1987 00:00', 'mm/dd/yyyy hh24:mi'), 3000, NULL,
20
INSERT INTO emp
(empno, ename, job, mgr,
hiredate, sal, comm,
deptno
VALUES (7839, 'KING', 'PRESIDENT', NULL,
TO_DATE ('11/17/1981 00:00', 'mm/dd/yyyy hh24:mi'), 5000, NULL,
10
INSERT INTO emp
(empno, ename, job, mgr,
hiredate, sal, comm, deptno
VALUES (7844, 'TURNER', 'SALESMAN', 7698,
TO_DATE ('09/08/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1500, 0, 30
INSERT INTO emp
(empno, ename, job, mgr,
hiredate, sal, comm,
deptno
VALUES (7876, 'ADAMS', 'CLERK', 7788,
TO_DATE ('05/23/1987 00:00', 'mm/dd/yyyy hh24:mi'), 1100, NULL,
20
INSERT INTO emp
(empno, ename, job, mgr,
hiredate, sal, comm, deptno
VALUES (7900, 'JAMES', 'CLERK', 7698,
TO_DATE ('12/03/1981 00:00', 'mm/dd/yyyy hh24:mi'), 950, NULL, 30
INSERT INTO emp
(empno, ename, job, mgr,
hiredate, sal, comm,
deptno
VALUES (7902, 'FORD', 'ANALYST', 7566,
TO_DATE ('12/03/1981 00:00', 'mm/dd/yyyy hh24:mi'), 3000, NULL,
20
INSERT INTO emp
(empno, ename, job, mgr,
hiredate, sal, comm,
deptno
VALUES (7934, 'MILLER', 'CLERK', 7782,
TO_DATE ('01/23/1982 00:00', 'mm/dd/yyyy hh24:mi'), 1300, NULL,
10
);i hope this helps .
Thanks,
P Prakash
Edited by: prakash on Jan 15, 2012 9:21 PM
Edited by: prakash on Jan 15, 2012 9:22 PM -
How to get the selection parameters from logical database into one of the t
Hi Sap ABAP Champians,
How to get the selection parameters from logical database into one of the tab in the tabstrip selection-screen.
Please help me for this
Thanks
BasuHi
Thanks, that will work, but then I'll have to insert code into all my reports.
I can see that "Application Server Control Console" is able to rerun a report.
This must mean that the Report Server has access to the runtime parameters.
But how?
Cheers
Nils Peter -
How to get the return values from a web page
Hi all :
how to get the return values from a web page ? I mean how pass values betwen webflow and web page ?
thank you very much
Edited by: jingying Sony on Apr 15, 2010 6:15 AM
Edited by: jingying Sony on Apr 15, 2010 6:18 AMHi,
What kind of web page do you have? Do you have possibility to for example make RFCs? Then you could trigger events (with parameters that could "return" the values) and the workflow could react to those events. For example your task can have terminating events.
Regards,
Karri -
How to get the current week from sysdate?
Hi sir,
i want to know how to get the current week from sysdate?
thanksHi Nicolas
It seems you like to check my post and also make commend ;) thanks for your attention
Have you ever read the posts above and given solutions ?Yes, I did
Have you read the docs ? Yes, I checked
What's the added value here ?Did youYou shared doc with solution(long one), I shared short one which point same solution(Check what Joel posted)..So what is benefit, As you can guess oracle docs are sometimes become so complicated as specialy for beginner...(At least it was like that for me and Belive me somedocs are still sooo complicated even for oracle coworkers ) But for you I dont know ;)
=> Why writting the PS in bold ?Why.. Let me think... Ohh Maybe I am looking some questions(many) and even user get answer they should not changed status so I am reading some posts and try to get problem and loosing time..
So I am putting that PS wiht BOLD because I dont wanna lose time my friend ;) Because While I am trying to help ppl here In same time I am trying to giving support to my customer prod systems. Which mean time is very important for me...
Hope my answer could satisfy you..
One important PS for you.. You may not like my posts (or someone) but my friend I become tired to read&answer and make commend to on your comment which is about my posts.
I am not newbie in forum(At least I fell like that) and I belive I know how I should make post..
Thank you
Regards
Helios -
How to get the extension Info from firefox? Do we have any firefox API to communicate with the browser? I couldnt see the HTML of the widget displayed in the toolbar how to access the widget using JS or any way
Hi,
Thanks for the suggestion. I've been playing around with some of the classes of the java.net package and java.io
Using the URL class i can get the content of the data from a STATIC page and output that response to file so that is does not display to the client broswer.
But this only works if the URL i give points to a static html page.
So the problem i'm getting is if i'm righting in arguments in the URL, this means that server needs to process the arguments i give and its sends back a dynamic result. Because its dynamic the URL class can not handle this and throws me an exception everytime :(
Have u ever tried to do some things like this?
Rahul -
How to get the Database type from weblogic Db connection
I want to use database version control in my application . that means different database type use different Sql Statement. Such as in weblogic7.0 if I create SqlServer JDBC pool then I will use some special Sqlserver sql Statement . such as some join statement. If I create Oralce JDBC pool then I have to use different Sql statement . because these two database support different Sql statement.
What my question is how to get the database type from the connection.For a normal jdbc driver you can use
Connection.getMetaData()
To get the meta data, in particular the getDatabase...() methods.
That might or might not work.
However, at the very least in the server you have access to the weblogic properties so you can parse the pool property to figure it out. -
How to get the XML messages from JMS Queue in BPM
I have one requirement in my application.we are sending XML messages to the JMS Queue.How to get the XML messages from JMS Queue and how to Extract the details from XMl.
can you please send me the code to get the XML messages from the JMS Queue.
Thank you,Hi,
Sure others will have some other ideas, but here's what I typically do to get the XML from a JMS queue. Inside the Global Automatic that pops the messages off the queue you'd have logic similar to this:
artifactInfoNodes as Any[]
xmlObject as Fuego.Xml.XMLObject = XMLObject()
load xmlObject using xmlText = message.textValue
. . . Once you have this, it's a matter of deciding what you want to do with the message. Most times you'll parse the XML (using XPATH statemens), set argument variables and create a work item instance.
Hope this helps,
Dan -
How to get the most current file based on date and time stamp using SSIS?
Hello,
Let us assume that files get copied in a specific directory. We need to pick up a file and load data. Can you guys let me know how to get the most current file based on date and time stamp using SSIS?
Thanks
thx regards dinesh vvhi simon
i excuted this script it is giving error..
Microsoft SQL Server Integration Services Script Task
Write scripts using Microsoft Visual C# 2008.
The ScriptMain is the entry point class of the script.
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
namespace ST_9a6d985a04b249c2addd766b58fee890.csproj
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
#region VSTA generated code
enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
#endregion
The execution engine calls this method when the task executes.
To access the object model, use the Dts property. Connections, variables, events,
and logging features are available as members of the Dts property as shown in the following examples.
To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
To post a log entry, call Dts.Log("This is my log text", 999, null);
To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
To use the connections collection use something like the following:
ConnectionManager cm = Dts.Connections.Add("OLEDB");
cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
To open Help, press F1.
public void Main()
string file = Dts.Variables["User::FolderName"].Value.ToString();
string[] files = System.IO.Directory.GetFiles(Dts.Variables["User::FolderName"].Value.ToString());
System.IO.FileInfo finf;
DateTime currentDate = new DateTime();
string lastFile = string.Empty;
foreach (string f in files)
finf = new System.IO.FileInfo(f);
if (finf.CreationTime >= currentDate)
currentDate = finf.CreationTime;
lastFile = f;
Dts.Variables["User::LastFile"].Value = lastFile;
Dts.TaskResult = (int)ScriptResults.Success;
thx regards dinesh vv -
How to get the list of top 10 tables grown last week or last few days
Hi All,
Please let me know, how to get the list of top 10 tables grown last week or last few days
ThanksPlease let me know, how to get the list of top 10 tables grown last week or last few days1.Oracle Version and OS info please ... ALWAYS
2.Do you have licensing options (Tuning and/or Diagnostics Pack) ?
3.Have you ran AWR/Statspack in last week or last few days
1.Because Oracle do not store auto tack the history of tables growth. See below link where one user has showed the possible way of manual track of table(s) growth :
Re: oracle tables growth
2.MOS Note for How To Get Table Growth History Information? [ID 1395195.1]
3.If you are in 10g than EM of 10g has something called Segmnet Statistics which can show you the growth of your table.
4.Other clue :
SQL> select * from table (dbms_space.object_growth_trend('SCOTT','EMP','TABLE'));
TIMEPOINT SPACE_USAGE SPACE_ALLOC QUALITY
17-SEP-12 11.06.20.228000 AM 1593 65536 GOOD5.A good script by Mice Ault for historical growth of segments within AWR:
http://www.dba-oracle.com/t_table_growth_reports.htm
Regards
Girish Sharma -
How to get the Reports of Change Tracking Table in MDM?
Hi!
Please tell me how to get the reports of Change Tracking Table in MDM which is a System table, directly from MDM without using any interface.
Thanks in advance for the reply.
With Best Regards
Devendra PandeyHi Devendra,
MDM can track changes on tables and fields. <u>The level of change tracking, and which tables/fields to track, are configurable in the MDM Console</u>. MDM opens a new database on the same database engine as the MDM repository and writes all change records to this database.
For information of various steps you can visit
<a href="http://help.sap.com/saphelp_mdm550/helpdata/en/45/c7b20339ee570ae10000000a114a6b/content.htm">this URL</a>
Regards,
Krutarth -
How to get second maximum salary from employee table(sql query)
how to get second maximum salary from employee table(sql query)
dude there is no matter of structure .........that user already said its from employee table ...............its basic table in sql and there is no need to specify the table structure
.........i think u got my point I think you are the one who didn't understand Sarma's point.
Give a man a fish and you feed him once. Teach a man how to fish and you feed him a life long.
>
and the query is
select max(sal) from emp where sal<(select max(sal)
from emp);
this will give the 2nd max salary from the emp tableBtw: You solution is bad, because it needs to scan and sort the table emp twice. And a better solution has been given already.
Message was edited by:
Sven W. - reordered statements
Maybe you are looking for
-
Hi Experts, IF Auto Update Statistics ENABLED in Database Design, Why we need to Update Statistics as a maintenance plan for Daily/weekly?? Vinai Kumar Gandla
-
Realised exchange difference by internal order
When clearing an open AP item with a payment, the realised exchange rate difference is posted to the P+L against the relevant cost centre (From the purchase order). However, the assigment to the internal order (also contained in the Purchase order)
-
Need to edit erroneous entries in iTunes Info autofill lists (artist, genre)
Bad entries in iTunes appear (autofill feature) when i am filling in artist, composer, genre, etc. Need to correct and clear out these bad entries. TIA for all your help. Regards, Allan.
-
Business Delegate- JSP or JSP- JavaBean, which one is better?
My current approach is to use a struts action to call a business delegate(pojo) which will go to the session facade and get database info then the JSP simply becames a FETCHER(which helps on reusablity since I can use them for many tables), but I als
-
How to open ALV Excel Inplace in new window
Hi everybody, I have an ALV report which is used in Excel Inplace mode. However, I'd like to have Excel to be opened in a new window and not in the ALV container. I do not want to manually export my data to Excel as described in many discussions here