Viewing A Teradata Alias - teradata

I wrote a query where I misspelled the alias I was using (this is pseudocode)
SELECT
ma.name
FROM mytable my
Teradata SQL Assistant did not give its usual error message saying ma does not exist, but ran for a long time and spooled out. I believe Teradata was processing all the rows in mytable.
When I changed the column selector to my.name the query ran as expected.
My question is, is it possible to see what Teradata SQL Assistant thinks the value of ma is?
Is there some setting which might define the default value of ma?
ma is not a column name in mytable

Related

MariaDB: SELECT INSERT from ODBC CONNECT engine from SQL Server keeps causing "error code 1406 data too long"

Objective: Using MariaDB I want to read some data from MS SQL Server (via ODBC Connect engine) and SELECT INSERT it into a local table.
Issue: I keep geting "error code 1406 data too long" even if source and destination varchar fields have the very same size (see further details)
Details:
The query which I'm trying to execute is in the form:
INSERT INTO DEST_TABLE(NUMERO_DOCUMENTO)
SELECT SUBSTR(TRIM(NUMERO_DOCUMENTO),0,5)
FROM CONNECT_SRC_TABLE
The above is the very minimal subset of fields which causes the problem.
The source CONNECT Table is actually a view inside SQL Server. The destination table has been defined so to be identical to the the ODBC CONNECT Table (same field names, same NULL constranints, same filed types ans sizes)
There's no issue on a couple of other VARCHAR fields
The issue is happening with a filed NUMERO_DOCUMENTO VARCHAR(14) DEFAULT NULL where the max length from the input table is 14
The same issue is also happening with 2 other fields ont the same table
All in all it seems to be an issue with the source data rather then the destination table.
Attemped workarounds:
I tried to force silent truncation but, reasonably, this does not make any difference: Error Code: 1406. Data too long for column - MySQL
I tried enlarging the destination field with no appreciable effect NUMERO_DOCUMENTO VARCHAR(100) DEFAULT NULL
I tried to TRIM the source field (hidden spaces?) and to limit its size at source to no avail: INSERT INTO DEST_TABLE(NUMERO_DOCUMENTO) SELECT SUBSTR(TRIM(NUMERO_DOCUMENTO),0,5) FROM CONNECT_SRC_TABLE but the very same error is always returned
Workaround:
I tried performing the same thing using a FOR x IN (src_query) DO INSERT .... END FOR and this solution seems to work: this means that the problem is not into the data itself but in how the engine performs the INSERT SELECT query

Error with SQLite query, What am I missing?

I've been attempting to increase my knowledge and trying out some challenges. I've been going at this for a solid two weeks now finished most of the challenge but this one part remains. The error is shown below, what am i not understanding?
Error in sqlite query: update users set last_browser= 'mozilla' + select sql from sqlite_master'', last_time= '13-04-2019' where id = '14'
edited for clarity:
I'm trying a CTF challenge and I'm completely new to this kind of thing so I'm learning as I go. There is a login page with test credentials we can use for obtaining many of the flags. I have obtained most of the flags and this is the last one that remains.
After I login on the webapp with the provided test credentials, the following messages appear: this link
The question for the flag is "What value is hidden in the database table secret?"
So from the previous image, I have attempted to use sql injection to obtain value. This is done by using burp suite and attempting to inject through the user-agent.
I have gone through trying to use many variants of the injection attempt shown above. Im struggling to find out where I am going wrong, especially since the second single-quote is added automatically in the query. I've gone through the sqlite documentation and examples of sql injection, but I cannot sem to understand what I am doing wrong or how to get that to work.
A subquery such as select sql from sqlite_master should be enclosed in brackets.
So you'd want
update user set last_browser= 'mozilla' + (select sql from sqlite_master''), last_time= '13-04-2019' where id = '14';
Although I don't think that will achieve what you want, which isn't clear. A simple test results in :-
You may want a concatenation of the strings, so instead of + use ||. e.g.
update user set last_browser= 'mozilla' || (select sql from sqlite_master''), last_time= '13-04-2019' where id = '14';
In which case you'd get something like :-
Thanks for everyone's input, I've worked this out.
The sql query was set up like this:
update users set last_browser= '$user-agent', last_time= '$current_date' where id = '$id_of_user'
edited user-agent with burp suite to be:
Mozilla', last_browser=(select sql from sqlite_master where type='table' limit 0,1), last_time='13-04-2019
Iterated with that found all tables and columns and flags. Rather time consuming but could not find a way to optimise.

Whats the correct syntax for on conflict do update sqlyte?

I am trying to insert clients on a table(importing them from a csv), the email column needs to be unique(in the csv the a client can appear more than one time, the last instance has the correct info) and the ids are created with an autoincrementing value (this is why i cant use select or replace), im trying to use the syntax found in the sqlite guide(and in every question about ON CONFLICT DO UPDATE found here) but sqlite throws a
SQL logic error near "ON" :syntax error
the query goes like this(using VB)
sqlQuery = "INSERT INTO clients(name1,name2,address1,address2,plz,city,country,phoneNumber1,phoneNumber2,cellPhoneNumber,fax,email) VALUES (?,?,?,?,?,?,?,?,?,?,?,?) ON CONFLICT(email) DO UPDATE SET name1=excluded.name1,name2=excluded.name2,address1=excluded.address1,address2=excluded.address2,plz=excluded.plz,city=excluded.city,country=excluded.country,phoneNumber1=excluded.phoneNumber1,phoneNumber2=excluded.phoneNumber2,cellPhoneNumber=excluded.cellPhoneNumber,fax=excluded.fax,email=excluded.email;

Invalid object name 'product_Design'

I am getting this error while saving my data into the table. I have already created a 'product_Design' table in my database. I am using Sql Server 2008. Everything is working fine on local host but not on the server. I also tried to insert data in different tables and its working but I am just not able to insert data in this(product_Design) table ? I really need help regarding this thing.
here is my sql query
insert into z3ctjholo.dbo.product_Design values(#prodID, #productName, #designName, #designPath, #finalDesign, #front, #cont, #divHeight, GETDATE(), 0, 1)
I also tried this query
insert into product_Design values(#prodID, #productName, #designName, #designPath, #finalDesign, #front, #cont, #divHeight, GETDATE(), 0, 1)
Both the queries are generating error. Please help me out.
Thanks..
So finally i found what is the problem. if you ever face such kind of problem then execute this command in sql server and see whether your table is connected to any schema apart from dbo. Use this statement to check whether the table is connected to any other schema.
use yourDatabaseName
Then
SELECT * FROM INFORMATION_SCHEMA.TABLES
after that if you find that your table is connected with other schema apart from dbo then use your any statement like this
select * from schemaName.tableName
(eg. my schema name is z3ctjholo and my table name is product_Design)
so my statement would be like this
select * from z3ctjholo.product_Design
what i was doing wrong, i was using two schema names (z3ctjholo.dbo.product_Design).
I hope it will help someone..
Thanks...
There are two reasons, I can find so far.
1. Either the connection settings in web.config is incorrect.
2. your database is case sensitive collation and so check the name with case. May be you have created the table with name Product_Design and trying to insert in product_Design, in this case also, the command may not work.
Please check both the points.

Copied database from live server doesn't allow me to perform inserts

After I copied the SQL Server database from the server and changed the connection string, the database appears to be read-only, but I try inserting a new node it gives me this error:
Cannot insert the value NULL into column 'ID', table
'Theshuk.dbo.Banners'; column does not allow nulls. INSERT fails. The
statement has been terminated.
This does not occur when I use the live server's database.
Any ideas?
Thanks
i have seen some weird things like that in the identity not sticking around in a database migration. not sure the cause, but it sounds like you are probably just missing an identity that was there in the other location. check all your tables to see that you have identities specified where you expect them.
The error just means: you cannot insert the values that you're trying to insert. As the error clearly states:
Cannot insert the value NULL into column 'ID', table
'Theshuk.dbo.Banners'; column does not allow nulls.
So it seems you're trynig to insert something into that table, and the table requires a value for ID and you're not supplying one.
That's all there is - add that column and a value for it to your INSERT statement and you should be fine.

Resources