I just set up a teradata JDBC database through Oracle SQL Developer. I can't get the 'DESCRIBE' command to work, or the 'HELP TABLE' command (usually the case with teradata).
If I put in DESCRIBE tablename ; I get error:
[Teradata Database] [TeraJDBC 14.10.00.26] [Error 3706] [SQLState 42000] Syntax error: expected something between the beginning of the request and the word 'DESCRIBE'.
If I use HELP TABLE tablename ; it gives me a help menu internal to Oracle sql developer
Anyone else have this issue? or know any alternatives to the DESCRIBE command?
Try this:
SHOW TABLE $database.$table
Related
I am populating data into db2 from my local machine (BankAccounts.sql) while executing the file I'm getting the below error Error message DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=MCX28303.BANKACCOUNTS, DRIVER=4.26.14
Stuck don't know what to do next?
You should learn how DB2 tells you what happened.
In this case the database tells you the code "-204" and the message "MCX28303.BANKACCOUNTS".
The code you have to look up here: ( Which Db2 are you using? this one is for z/OS version 12)
https://www.ibm.com/support/knowledgecenter/SSEPEK_12.0.0/codes/src/tpc/n204.html
And the message points to your mistake.
Finally the IBM-documentation often gives you advice what to do (see "Programmer response").
In my case there is an issue with schema. As you are using MCX28303 as schema you can try to set schema first like
set schema = MCX28303;
and after that you can run your query without schema.
I tried this way and it's working for me.
I'm trying to access a SQL Express database using Python, but I keep getting an incorrect syntax error. I've tried a few variations based of other examples I've seen, but nothing's working.
import pyodbc
conn = pyodbc.connect(Trusted_connection='yes',
driver='{SQL Server}',
server='VACE1\RCARCHIVE',
database='TestDB')
cursor = conn.cursor()
cursor.execute("select * from 100000MTL1")
for row in cursor:
print(row)
The error is
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '100000'. (102) (SQLExecDirectW)")
I've tried changing the database and the name of the database, but I'm not sure if that is where the error is exactly, so I'm totally stuck now.
Escape your table name like this
select * from [100000MTL1]
since table names usually don't start with numbers.
I have a script that used to run just fine from Teradata SQL Assistant. I am unable to get the exact same script to run from SQL Workbench/J. I have isolated the problem to one specific line. Here's the query:
SELECT
variable1 as name1,
variable2 as name2,
CONCAT(TRIM(variable3), ':', trim(variable4)) as name3
variable4 as name4,
FROM
table1
WHERE
variable4 between '2017-01-01' AND '2017-01-31';
The problem is the CONCAT line. If I comment that line out, code runs fine. If I leave that line in, I get the unhelpful message:
[Teradata Database] [TeraJDBC 16.10.00.07] [Error 3706] [SQLState 42000]
Syntax error: expected something between '(' and the 'TRIM' keyword. [SQL State=42000,
DB Errorcode=3706]
1 statement failed.
I say unhelpful, because that makes it sound like a syntax error, but this isn't a syntax error as far as Teradata is concerned. The exact same code ran fine on Windows Teradata SQL Assistant. But since OSX Teradata SQL Assistant is a dumpster fire, I have to try and run the script in SQL Workbench J.
Help, please?
There's no concat function in Teradata SQL, it's an ODBC function (sometimes) automatically translated by the ODBC driver to valid syntax. But SQL Workbench uses JDBC, which doesn't support this function.
Simply switch to Standard SQL ||:
TRIM(variable3) || ':' || trim(variable4)
Trying to execute the statement
select *
from RU_VARIANCE_HISTORY
but I'm getting the error
DB2 SQL Error: SQLCODE=-901, SQLSTATE=58004,
SQLERRMC=Invalid collation ID, DRIVER=4.21.29
Tried searching but unable to find the solution.
This can happen if DB2 thinks the statement is really too long or too short. Try adding a semicolon to the end of your statement - this worked for me with the same error.
I am able to retrieve data from the same database table but am not able to isert
The error which i get is
DB2 SQL error: SQLCODE: -516, SQLSTATE: 26501, SQLERRMC: null
IBM's documentation suggests that
the currentSchema property does not
match the schema name of the tables
and indexes that you created.
(Although the above is for z/OS, I would expect that the Java DB2 implementation is the same)
When you got SQLCODE that retreive from DB2
you can use following command for describe
DB2 ? SQL-<ERRORCODE>
example
DB2 ? sql-407