Any ideas about this problem's automization...
Hi all
Please suggest any sql query for below problem:
I want to compare two schema tables(same in all schemas but altered late in either case) to display the differences in schemas. for this we can use TOAD SOFTWARE but it is very easy to compare the schema using this software but difficult to display the details (differences) according to my requirement. so can you anybody suggest any query to extract the following model:
for example:
Schema1 = emp table
schema2 = emp table
desc emp in schema1:
empno number(10) notnull
ename varchar2(20)
sal number(30)
desc emp in schema2:
empno number(10) notnull
empname varchar2(19) notnull
sal number(30)
out put requirement:
Schema |TableName| Fields | Datatype | Null/Notnull | Constraint Schema2|TableName| Fields | Datatype | Null/Notnull
EMP EMPNO NOTNULL EMP EMPNO NOT NULL
SAL SAL
ENAME VARCHAR2(20) EMPNAME VARCHAR2(19) "ADDITIONAL
(name change) NOT NULL
CONSTRAINT"
let me explain above example, in the given two same tables in different schema, in the output
those fields which are matched in terms of all i.e field name,datatype,constraint,null/notnull
should be displayed first.
Then those field which have differences should be displayed by giving appropriate comments
like "colmn name changed if there is difference between col names in both schemas"
In some cases, we cannot find the table in one schema, it should print "table not found on the schema2 side in the above output
Very important note is that Schema1 should reflect same as
schema2 tables.
One more thing is in the above output : for ename field only datatype displayed, this is because for those
fields which have change in schema2, for that colomns only we have to display the datatype.
Thanks in advance
prasanth
Some sample code to get you started ...
SQL> desc core.emp
Name Null? Type
EMPNO NOT NULL NUMBER(10)
ENAME VARCHAR2(20)
SAL NUMBER(30)
DT NOT NULL DATE
Â
SQL> desc flip.emp
Name Null? Type
EMPNO NOT NULL NUMBER(10)
EMPNAME NOT NULL VARCHAR2(19)
SAL NUMBER(30)
DT DATE
Â
SQL> set lines 120
SQL> col owner format a10
SQL> col table_name format a10
SQL> col column_name format a10
SQL> col data_type format a10
SQL>
SQL> with t1 as
2 ( SELECT 1 src1
3 ,to_number(null) src2
4 ,owner
5 ,table_name
6 ,column_name
7 ,data_type
8 ,data_length
9 ,data_scale
10 ,nullable
11 FROM dba_tab_columns
12 WHERE owner = 'CORE'
13 AND table_name = 'EMP'
14 )
15 ,t2 as
16 ( SELECT to_number(null) src1
17 ,1 src2
18 ,owner
19 ,table_name
20 ,column_name
21 ,data_type
22 ,data_length
23 ,data_scale
24 ,nullable
25 FROM dba_tab_columns
26 WHERE owner = 'FLIP'
27 AND table_name = 'EMP'
28 )
29 ,src as
30 ( select table_name
31 ,column_name
32 ,data_type
33 ,data_length
34 ,data_scale
35 ,nullable
36 ,count(src1) cnt1
37 ,count(src2) cnt2
38 from ( select * from t1
39 union all
40 select * from t2
41 )
42 group by table_name
43 ,column_name
44 ,data_type
45 ,data_length
46 ,data_scale
47 ,nullable
48 )
49 ,similar_col as
50 ( select table_name
51 ,column_name
52 ,data_type
53 ,data_length
54 ,data_scale
55 ,nullable
56 from src
57 where cnt1 = cnt2
58 )
59 ,different_col as
60 ( select table_name
61 ,column_name
62 ,data_type
63 ,data_length
64 ,data_scale
65 ,nullable
66 from src
67 where cnt1 != cnt2
68 )
69 ,same as
70 ( select 'Same' text
71 ,cast(null as varchar2(30)) owner
72 ,s.*
73 from similar_col s
74 )
75 ,diff1 as
76 ( select 'Diff' text
77 ,t1.owner
78 ,d.*
79 from different_col d
80 ,t1
81 where t1.table_name = d.table_name
82 and t1.column_name = d.column_name
83 and t1.data_type = d.data_type
84 and nvl(t1.data_length,-1) = nvl(d.data_length,-1)
85 and nvl(t1.data_scale ,-1) = nvl(d.data_scale ,-1)
86 and t1.nullable = d.nullable
87 )
88 ,diff2 as
89 ( select 'Diff' text
90 ,t2.owner
91 ,d.*
92 from different_col d
93 ,t2
94 where t2.table_name = d.table_name
95 and t2.column_name = d.column_name
96 and t2.data_type = d.data_type
97 and nvl(t2.data_length,-1) = nvl(d.data_length,-1)
98 and nvl(t2.data_scale ,-1) = nvl(d.data_scale ,-1)
99 and t2.nullable = d.nullable
100 )
101 select * from same
102 union all
103 select * from diff1
104 union all
105 select * from diff2
106 order by 1 desc,4
107 ;
Â
TEXT OWNER TABLE_NAME COLUMN_NAM DATA_TYPE DATA_LENGTH DATA_SCALE N
Same EMP EMPNO NUMBER 22 0 N
Same EMP SAL NUMBER 22 0 Y
Diff CORE EMP DT DATE 7 N
Diff FLIP EMP DT DATE 7 Y
Diff FLIP EMP EMPNAME VARCHAR2 19 N
Diff CORE EMP ENAME VARCHAR2 20 Y
Â
6 rows selected.To get the desired side by side output you would have to slightly modify the above and do a full outer join ... unfortunately, in 9.2.0.1.0, I got ORA-03113 trying to use the ANSI full outer join syntax ... to fake it with the traditional syntax ...
SQL> set lines 200 pages 500
SQL> with t1 as
2 ( SELECT 1 src1
3 ,to_number(null) src2
4 ,owner
5 ,table_name
6 ,column_name
7 ,data_type
8 ,data_length
9 ,data_scale
10 ,nullable
11 FROM dba_tab_columns
12 WHERE owner = 'CORE'
13 AND table_name = 'EMP'
14 )
15 ,t2 as
16 ( SELECT to_number(null) src1
17 ,1 src2
18 ,owner
19 ,table_name
20 ,column_name
21 ,data_type
22 ,data_length
23 ,data_scale
24 ,nullable
25 FROM dba_tab_columns
26 WHERE owner = 'FLIP'
27 AND table_name = 'EMP'
28 )
29 ,src as
30 ( select table_name
31 ,column_name
32 ,data_type
33 ,data_length
34 ,data_scale
35 ,nullable
36 ,count(src1) cnt1
37 ,count(src2) cnt2
38 from ( select * from t1
39 union all
40 select * from t2
41 )
42 group by table_name
43 ,column_name
44 ,data_type
45 ,data_length
46 ,data_scale
47 ,nullable
48 )
49 ,similar_col as
50 ( select table_name
51 ,column_name
52 ,data_type
53 ,data_length
54 ,data_scale
55 ,nullable
56 from src
57 where cnt1 = cnt2
58 )
59 ,different_col as
60 ( select table_name
61 ,column_name
62 ,data_type
63 ,data_length
64 ,data_scale
65 ,nullable
66 from src
67 where cnt1 != cnt2
68 )
69 ,sd1 as
70 ( select 'same' text
71 ,o.owner
72 ,s.*
73 from similar_col s
74 ,(select owner from t1 where rownum <2) o
75 union all
76 select 'diff' text
77 ,t1.owner
78 ,d.*
79 from different_col d
80 ,t1
81 where t1.table_name = d.table_name
82 and t1.column_name = d.column_name
83 and t1.data_type = d.data_type
84 and nvl(t1.data_length,-1) = nvl(d.data_length,-1)
85 and nvl(t1.data_scale ,-1) = nvl(d.data_scale ,-1)
86 and t1.nullable = d.nullable
87 )
88 ,sd2 as
89 ( select 'same' text
90 ,o.owner
91 ,s.*
92 from similar_col s
93 ,(select owner from t2 where rownum <2) o
94 union all
95 select 'diff' text
96 ,t2.owner
97 ,d.*
98 from different_col d
99 ,t2
100 where t2.table_name = d.table_name
101 and t2.column_name = d.column_name
102 and t2.data_type = d.data_type
103 and nvl(t2.data_length,-1) = nvl(d.data_length,-1)
104 and nvl(t2.data_scale ,-1) = nvl(d.data_scale ,-1)
105 and t2.nullable = d.nullable
106 )
107 select nvl(sd1.text,sd2.text) text
108 ,sd1.owner
109 ,sd1.table_name
110 ,sd1.column_name
111 ,sd1.data_type
112 ,sd1.data_length
113 ,sd1.data_scale
114 ,sd1.nullable
115 ,sd2.owner
116 ,sd2.table_name
117 ,sd2.column_name
118 ,sd2.data_type
119 ,sd2.data_length
120 ,sd2.data_scale
121 ,sd2.nullable
122 from sd1,sd2
123 where sd1.table_name = sd2.table_name (+)
124 and sd1.column_name = sd2.column_name (+)
125 union
126 select nvl(sd1.text,sd2.text) text
127 ,sd1.owner
128 ,sd1.table_name
129 ,sd1.column_name
130 ,sd1.data_type
131 ,sd1.data_length
132 ,sd1.data_scale
133 ,sd1.nullable
134 ,sd2.owner
135 ,sd2.table_name
136 ,sd2.column_name
137 ,sd2.data_type
138 ,sd2.data_length
139 ,sd2.data_scale
140 ,sd2.nullable
141 from sd1,sd2
142 where sd1.table_name (+) = sd2.table_name
143 and sd1.column_name (+) = sd2.column_name
144 order by 1 desc nulls last, 4
145 ;
TEXT OWNER TABLE_NAME COLUMN_NAM DATA_TYPE DATA_LENGTH DATA_SCALE N OWNER TABLE_NAME COLUMN_NAM DATA_TYPE DATA_LENGTH DATA_SCALE N
same CORE EMP EMPNO NUMBER 22 0 N FLIP EMP EMPNO NUMBER 22 0 N
same CORE EMP SAL NUMBER 22 0 Y FLIP EMP SAL NUMBER 22 0 Y
diff CORE EMP DT DATE 7 N FLIP EMP DT DATE 7 Y
diff CORE EMP ENAME VARCHAR2 20 Y
diff FLIP EMP EMPNAME VARCHAR2 19 NNow, having done all this ... was it worthwhile? Wouldn't comparing the output of dbms_metdata.get_ddl been as good (actionable) as this? Hmmm.
Cheers.
Similar Messages
-
I am using PP 2014 CC and it and or Encoder keep crashing.. using iMac computer with Yosemite OS anyone have any ideas about this issue?
Hi,
Please give this a try: Premiere Pro CC, CC 2014, or 2014.1 freezing on startup or crashing while working (Mac OS X 10.9, and later)
Thanks,
Rameez -
HT3275 Any ideas about this error message? (error -1)
Any ideas about this error message?
"The backup disk image “/Volumes/Data/ MacBook Pro.sparsebundle” could not be accessed (error -1)."Standard Lion networking .. Reboot the TC or use the disconnect all users in the AU.. it has not closed the sparsebundle correctly from last time.. or has simply forgotten where the TC is.
It is reported at least once a day here.
See C17
http://pondini.org/TM/Troubleshooting.html -
I am getting for the last days a constant error msg while downloading or visiting iTune store: "network connection was lost" (sometimes also ways it was "reset" instead). But, the network is working (I can make othe rdownloads and visit to other internet sites). Any idea about the problem?
Mac server or Windows server? Have you checked her permissions/access vs another user not having the issue?
-
Hi. My Iphone 4 suddenly is completely off though it is charged. I even made someone else call my number in vain. I've been trying to switch it on, but in vain. First time this problem happened. I have no idea what happened to the phone. it rings correcly in the other line. I just plugged in again with the charger but I dont see any signal. please help if somebody has an idea as I have no clue..Thanks.
Miksu,
Great ideas, thank you. I have two USB cables, both of which I have tried on my computer and my friends. Unless I got two bad cables in a row, I somewhat doubt it is the cause of my problem but it is still possible.
I haven't yet tried any other form of connecting to my PC though I plan to borrow a neighbors Bluetooth USB Dongle tonight if I can and see if that works. I don't think any of my friends have a Nokia that uses the same cable, but I could check that too I guess.
Any other suggestions will still be appreciated as I really doubt that these will solve the problem. On the other hand, you MAY BE RIGHT about my USB port on my phone. It is possible that it could be damaged, though I have used the same port with a headset and that worked. It might be that it was using a different pin configuration though. I also plan to try resetting to factory settings, and flashing/updating the firmware if I can find an authorized service agent of Nokia in my area. My cell provider may be able to help me in that regard, but it would be a couple weeks because they have to wait for a special data cable.
I appreciate all the advice. Any other ideas would still be welcome because I think there have been a few others who have had trouble with my particular model of phone. A funny thing is that my phone model doesn't seem to be listed as compatible with PC Suite, but Nokia told me it was. Hopefully it's just a typo. -
Any ideas about interface problems on 2014.1.1?
On a fresh install of 2014.1.1 on a new macbook pro I am having interface problems. The Edge program locks up after a few minutes or the cursor won't show what's being selected, items disappear, sometimes get the "Save your work, error occurred" message and other odd interface behavior. Are there any known issues or likely culprits that might cause this sort of thing?
Thanks for jumping in. Yes, I've restored prefs and even uninstalled all (including prefs) and reinstalled. If it helps at all, I run several cloud apps (googledrive, dropbox, icloud, box, transporter, etc.). Other installed items include a Wacom tablet driver, latest Java, Flash player, Logitech mouse driver. Other than those the mac is brand new with no unusual system mods yet.
Appreciate any ideas. -
Is it possible to access and not leave a calling card of access in the system? I had a service result that went bad, and required another service result that reinstalled the Mt.Lion. Bad being that they did not install as the paper work stated. OSX 10.8.5 questions my ability to protect access. Any thoughts on technical support being to technical with personal information?
Go here:
http://www.apple.com/support/itunes/contact/
and follow the instructions to report the issue to the iTunes Store.
Regards. -
I tried reseting the pram, reinstalling the software, plugging the headphone jack in and out, deleting playlist but nothing works. on the external clone, the output works with noise but still no input device.
can i use a sound card instead?If you just had the system repaired for water damage what did they replace? If it was the Logic board then all parts should work and if they don't, like the sound, then they didn't fix it correctly and you should take it back to them for a proper fix.
-
Any ideas about creating persistant object during execution?
As a newbie, I wrote a badly designed applet which is used to share different keys with different devices. Now I got a problem about if the number of devices increased, how to generate new key objects during the execution and store it as a persistant object. I would use a (short) variable to restrict the number of devices and I only know using JCSystem. Transaction to update a byte array. Does anyone has good ideas about this problem?
Could you explain a little more detail about what you are trying to do? Are you allocating a certain amount of space for keys at install time and setting a limit to this or do you plan to allocate memory at runtime as new devices come along? Do you have some sample code to share that would clarify what you are trying to do?
I would suggest creating all your data up front and tracking which keys are allocated.
- Shane -
Since upgrading to OSx 10.9, I cannot place my music for iPhoto slideshows. The only music that works is the Sample and Theme music that comes with iPhoto. Any idea of what to do about this problem?
In iTunes go File -> Library -> Organise Library -> Reorganise Library.
Then quit and restart iPhoto.
Credit to user keysandfood who figured that one out. -
This was previously a problem with one of the older versions if iTunes and had stopped happening for a while with the new version. Any ideas why this may have recurred and how to fix it?
Go to the settings in your Jeep, "forget" the iPhone. And on the iPhone "forget" the jeep. Then put the Jeep in Pairing Mode and tap Settings/BlueTooth on the phone and pair them anew (which sounds less confusing than "repair them").
-
When I compose an email in either gmail or yahoo, the cursor lags behind for about 2 seconds. This does not happen when I compose an email with Safari or Chrome. I am using a Mac with Firefox version 3.6.3. Any idea why this happens?
== This happened ==
Every time Firefox openedtry
The Reset Firefox feature can fix many issues by restoring Firefox to its factory default state while saving your essential information.
Note: ''This will cause you to lose any Extensions, Open websites, and some Preferences.''
To Reset Firefox do the following:
#Go to Firefox > Help > Troubleshooting Information.
#Click the "Reset Firefox" button.
#Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
#Firefox will open with all factory defaults applied.
Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
Did this fix your problems? Please report back to us!
Thank you. -
trying to buy more storage on the cloud, response is 'there was a problem - try again later' its been doing this over the last two hours - any ideas what the 'problem' is please (assuming its not me) - thanks
Additional info on this:
I strongly suspect this is time machine-related. Even though time machine has been turned off, this happens at intervals of exactly one hour.
A single entry appears in the kernel log at the precise moment the (first) popup error box appears. This is:
"AppleSRP started."
Anyone have any clue how to go about diagnosing or fixing this? I don't even mind trying something brute force (short of wiping the HD and reinstalling lion, which I really DON'T want to do; I don't mind a non-destructive reinstall). -
Problem tranferring old iPhone 3GS (ios 6.1.6) to new iPhone 5S (ios 8.1.2) through iTunes on my iMac computer (OSX 10.5.8) . I have backed up the 3GS this way since purchase of 3GS. The computer does not seem to recognize the 5S is there -- no setup assist is appearing on screen. Any ideas welcome.
this may not be your problem my according to the tech specs on apple.com the 5s requires:
Syncing with iTunes on a Mac or PC requires:
Mac: OS X v10.6.8 or later
PC: Windows 8; Windows 7; Windows Vista; or Windows XP Home or Professional with Service Pack 3 or later
iTunes 11.1 or later (free download -
I just got a notice to update my firefox to 4.0 and when I downloaded the new software it indicated: that I can't open the application "Firefox" because it is not supported on this architecture. Any ideas about what might be wrong and how to fix it?
Firefox 4 requires at least OS X 10.5 and an Intel Mac. There is a third party version of Firefox 4 that runs on OS X 10.4/10.5 and PPC Macs, for details see http://www.floodgap.com/software/tenfourfox
If you prefer, you can get the latest version of Firefox 3.6 from http://www.mozilla.com/en-US/firefox/all-older.html
Maybe you are looking for
-
Changing the Montoring Configuration
I am trying to set up database monitoring. I navigated to a database on the host. I then pressed the Monitoring Configuration link The first page of a wizard appears. I enter the proper password for the Dbsnmp monitor name. I press the next button an
-
Intel-iMac Keyboard not working...
So I've had my Intel-iMac for a year and some change now and have had no problems until today when my keyboard stoped working. I have tried plugging into different usb ports but nothing. Each time I plug into a usb port the caps lock light does flash
-
Exact code to develop a BDC program for Incoming Invoices that updates the records depending on the source data file from the external systems.
-
Hi, Most albums on my iPod play in sequence, i.e. I choose the first track of an album and it continues to play the whole album track by track. Some albums however only play the track I selected then goes back to the main menu when this has finished.
-
Poor quality of stream reception with iTunes 12
I have a playlist containing url streams for most of the channels from Swedish Radio. I have been using it for years. After the update to iTunes 12 these streams are more or less useless. When selecting and starting a stream I usually get a laud buzz