So I have been trying to replicate some oracle sql I have to redshift but I'm not too familiar with redshift, and I'm having some syntactical errors while replicating, I believe there's no FORCE in redshift, then how would i replicate this line of code from oracle sql to redshift sql. I have been getting syntax errors near FORCE
CREATE OR REPLACE FORCE EDITIONABLE VIEW "dev"."daily_rates" ("FR_CURRENCY", "CURRENCY", "C_DATE", "C_RATE") AS
SELECT DISTINCT GL.G_RATES.FR_CURRENCY, GL.G_RATES.CURRENCY,
GL.G_RATES.C_DATE, GL.G_RATES.CRATE
FROM GL.G_RATES
WHERE GL.G_RATES.C_T='Corporate'
FORCE makes objects without validating the query, if you are sure your query works you can ignore it.
Amazon Redshift CREATE VIEW Docs
EDITIONABLE is a feature in oracle that let you have several edition of same object in database and I don't know if any other DB engine out there has this feature, so I guess you have to remove those two options when you create your object in Redshift.
Related
I have developed some SQL that reads from a redshift table, does some manipulation (esp listagg some fields), and then writes to another redshift table.
When I run the SQL using SQLWorkbench it executes successfully. When I embed it in a Tableau Prep flow (as "Complex SQL") I get several of these errors: "System error: AqlProcessor evaluation failed: [Amazon][Support] (40550) Invalid character value for cast specification." Presumably these relate to my treatment of data types. What I don't is what is so difference in the environment that would cause different results like this? Is it because SQLWorkbench and Tableau Prep use different SQL interpreters? Or is my question too broad to even speculate without going through the actual code?
Best guess is that Tableau, which has knowledge of DDL, is add some CAST() operations to the SQL. SQLWorkbench is simpler and is pushing the SQL to Redshift as written. This is based on there being no explicit CASTs in your SQL but an error message that identifies a CAST().
Look at stl_querytext for these two queries and see if they are being given to Redshift differently by the two benches. I suspect this will give you some clues to go on.
If there are no differences in the SQL then the issue may be with user / connection differences and more info will likely be needed about the issue.
I am trying to CREATE VIEW in access in SQL view but I am getting a syntax error for CREATE TABLE which is highlighting the word VIEW. This is in Access 2016 via Office 365 (latest update as of 2/11/2019). The SELECT statement works by itself, but the CREATE VIEW command isn't. My book (Concepts of Database Management) is designed for use specifically alongside Access. My code is as such:
CREATE VIEW TopLevelCust AS
SELECT CustomerNum, CustomerName, Street, Balance, CreditLimit
FROM Customer
WHERE CreditLimit>=10000
;
As already stated in Lynn's answer, if you want to execute this query, you can do that after turning on SQL server compatible syntax.
However, you can also execute the query using an OLEDB connection to the Access database.
You can even do this using VBA and the already preset CurrentProject.Connection object:
CurrentProject.Connection.Execute "CREATE VIEW Query1 AS SELECT 1"
Without turning on SQL server compatible syntax, DDL statements executed from Access itself are fairly limited (for example, you can also not use the Decimal data type). But these DDL statements are not really meant to be executed from Access itself, VBA provides way better tools to create queries (that also allows creating pass-through queries, for example).
According to the asker and other users, enabling ANSI-92 SQL in the database options will allow you to execute the DDL statement CREATE VIEW.
File > Options > Object Designers > Query Design.
According to Wolfgang, under the hood, this actually creates a query.
<SoapBox>
It surprises me that your text reference requests you to execute statements that aren't enabled by default in Access, especially without a special note screaming at you that you need to enable a special option before database creation. ¯\_(ツ)_/¯
</SoapBox>
My procedure has large query syntax, many "nested if else" when I create it on one SQL Server I get this error:
Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries.
but when I create that on another server, it is created without error. I know the procedure has poor performance but why that is created correctly on another server
Does it depend on server config or database feature ?
when i create that on another server,that is created without error
Reason is that the two version is not same . I think you 1st server is older than 2012sp1 that's why you got that error. you can check this link
I have an application that is supposed to support two types of databases SQL SERVER and ORACLE. So we've been working forever on SQL Server and now we are making this support.
My idea was to create a tool to generate the scripts of creating the database using CMO then convert those scripts to PL/SQL Oracle scripts and run them on Oracle.
My questions are:
Is this syntax conversion possible in code?
I need a guideline to make this kind of syntax conversion.
Do you have a better suggestion to maintain two types of databases (i mean when making a change of one of them, we dont have to make it to the other. we need a tool to make that change.)?
If you write using standard sql it should be mostly portable. Eg use fetch instead of top, SET #a=.. instead of Select #a=.. Use Merge for updates instead of join updates, CURRENT_TIMESTAMP instead of getdate() etc.
I'm using Oracle PL/SQL developer. I have two databases live and dummy.
I have been using the dummy database for development and now i need to add all the new tables and data into the live database without effecting the data currently stored in it.
I also need to copy over all the new sequences and triggers.
I've tried exporting a table but had no luck and using the SQL view i only get the SQL for the creation of the data and not the data it contains.
I also found this SQL code
COPY FROM test#DUMMY - CREATE test -USING SELECT * FROM test;
But it asks me for a name and password of which I dont know and then fails after 3 attempts. It then goes on to say there is a syntax error as well.
I'm still fairly new to using Oracle and any help would be appreciated.
You can do that using datapump.
or if you want to copy from schema to schema
create table shecma2.old_table
as
select * from schema1.old_table
or using oracle sql developer - here is link.
Try:
CREATE TABLE NEWTABLE AS SELECT * FROM OLDTABLE;