on 2015 Nov 23 6:17 PM
12.0.1.4266
I have a script to create a database which includes a remote server and several proxy tables. The remote server is not yet available is there a way to force the creation of these existing tables?
Thanks,
Jim
There is a way to do this. It is not documented and is not recommended to be used since it can lead you into trouble - e.g. when you do this there is no check done to confirm that the table column specifications match the remote table specifications - but if you know what you are doing and know that your column specifications are correct (which should be the case if you are rebuilding a database) then here is what you can use:
CREATE [ EXISTING ] TABLE name ( _column-specifications_ )
AT '...location-specification...'
LOCAL ONLY;
The LOCAL ONLY clause tells the server to not check the definition of the table and will therefore not attempt to connect to the remote server. USE WITH CAUTION!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That would have saved me a lot of time.
> if you know what you are doing
When did that become a necessary condition for documenting a feature?
> USE WITH CAUTION!
Is there anything in SQL that can be used without caution?
IMO, if some option or setting is rarely needed, simply don't make it the default rather than hiding its existence.
Just to understand:
Does the LOCAL ONLY clause only make a difference when the CREATE TABLE statement is executed (by omitting the remote access and thereby ignoring the remote schema) or does it have an influence on the usage of the proxy table itself, i.e. when doing queries?
(I'm asking as even a "regularly created" proxy table bears the risk that the according remote object may not be accessible lateron or may have been dropped or altered in a way that the proxy table's definition does not fit anymore or that permissions have been changed, so that caution is true for all proxy tables...)
And just another question:
Am I correct that the EXISTING clause is ineffective when LOCAL ONLY is used?
(Frankly, I would expect that CREATE EXISTING TABLE would not need the LOCAL ONLY undocumented clause, not even for "script compatibility" - if you expect the exceptional case that the remote table may not be existing/accessible when creating proxy objects, you explicitly have to add that LOCAL ONLY clause, and then you could as well replace CREATE EXISTING TABLE with CREATE TABLE, particularly as the column definition - optional for CREATE EXISTING TABLE - cannot be optional with LOCAL ONLY. - Sorry, I should not comment on an undocumented feature...)
Yes, it only affects the creation time. You are correct that there are other conditions - e.g. changes to the remote table made on the remote server - that can also lead to the proxy table definition getting out of sync with the remote table definition. In these cases the user needs to take action to update the proxy table definition.
The LOCAL ONLY says "don't do anything other than put the meta data into the local system tables" and hence it does not do anything to the remote server / database. Beyond that, the operation is identical to when LOCAL ONLY is not used. If you used CREATE TABLE then the "normal" operation would have been to go to the remote server and create the table, so if you used LOCAL ONLY then the remote table had better already exists (in which case it would have made more sense to have used CREATE EXISTING TABLE).
Note also that if you use CREATE TABLE ... LOCAL ONLY then when (and if) the proxy table is dropped then the server will attempt to also drop the remote table. If you had used CREATE EXISTING TABLE ... LOCAL ONLY then the server will not attempt to drop the remote table when the proxy table is dropped.
HTH
the user needs to take action to update the proxy table definition.
Is that possible? AFAIK (see that according FAQ) one would have to drop and re-create the proxy table...
That is correct.
Yes, it is documented on the Creating Proxy Tables page in the documentation. See the second paragraph in the Context section.
Quote:
If you use the CREATE TABLE statement to create both a local and remote table, and then subsequently use the DROP TABLE statement to drop the proxy table, the remote table is also dropped. Use the DROP TABLE statement to drop a proxy table created using the CREATE EXISTING TABLE statement however. In this case, the remote table is not dropped.
Hm, I have the impression that this should make it to the DROP TABLE documentation, too...
User | Count |
---|---|
67 | |
10 | |
10 | |
10 | |
10 | |
8 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.