in teradata i have two tables . Both of them display data correctly and fine
select * from table1;
select * from table2;
however the following query throws an error
string contains untranslatable character
insert into table1
(varone)
select varone from table2
;
why could that happen ? both tables are in teradata which means they do not have any bad characters otherwise they would not be in teradata in the first place
Try to check charset of the table, i think it are differ.
show table table1
show table table2
If varone contains unicode chars you can get such error... or check fields type
Related
I have a table SIGHTINGS(NAME, PERSON, LOCATION, SIGHTED), and I'm trying to insert a new row into that table with the following query:
INSERT INTO SIGHTINGS (NAME, PERSON, LOCATION, SIGHTED)
VALUES ('Douglas dustymaiden', 'Person B', 'Double Mountain', '2005-11-28');
But it's returning this error:
[2017-12-04 17:08:18] [1] [SQLITE_ERROR] SQL error or missing database (sub-select returns 6 columns - expected 1)
I've looked up the correct syntax for sqlite inserts here, and from what I can tell, the insert is written correctly. Can someone tell me why it's throwing this error instead of doing the insert? I'm using DataGrip 2017 if that helps identify any issues.
EDIT:
Here's the trigger I added to the database. The insert works without the trigger.
CREATE TRIGGER SightingLocationError
BEFORE INSERT ON SIGHTINGS
FOR EACH ROW
WHEN NEW.LOCATION NOT IN FEATURES
BEGIN
SELECT RAISE(ABORT, 'Error: Insert into the SIGHTINGS table references location that is not found in the database.');
END;
WHEN NEW.LOCATION NOT IN FEATURES
The FEATURES table has six columns, so the database does not know how it should search for the location value.
Use an explicit subquery to return the column you want to use for this:
WHEN NEW.LOCATION NOT IN (SELECT xxx FROM FEATURES)
Problem description
I want to search for the query = Angela in a database from a table called Variations. The problem is that the database does not Angela. It contains Angel. As you can see the a is missing.
Searching procedure
The table that I want to query is the following:
"CREATE TABLE IF NOT EXISTS VARIATIONS
(ID INTEGER PRIMARY KEY NOT NULL,
ID_ENTITE INTEGER,
NAME TEXT,
TYPE TEXT,
LANGUAGE TEXT);"
To search for the query I am using fts4 because it is faster than LIKE% especially if I have a big database with more than 10 millions rows. I cannot also use the equality since i am looking for substrings.
I create a virtual table create virtual table variation_virtual using fts4(ID, ID_ENTITE, NAME, TYPE, LANGUAGE);
Filled the virtual table with VARIATIONS insert into variation_virtual select * from VARIATIONS;
The selection query is represented as follow:
SELECT ID_ENTITE, NAME FROM variation_virtual WHERE NAME MATCH "Angela";
Question
What am I missing in the query. What I am doing is the opposite of when we want to check if a query is a subtring of a string in a table.
You can't use fts4 for this. From the documentation:
SELECT count(*) FROM enrondata1 WHERE content MATCH 'linux'; /* 0.03 seconds */
SELECT count(*) FROM enrondata2 WHERE content LIKE '%linux%'; /* 22.5 seconds */
Of course, the two queries above are not
entirely equivalent. For example the LIKE query matches rows that
contain terms such as "linuxophobe" or "EnterpriseLinux" (as it
happens, the Enron E-Mail Dataset does not actually contain any such
terms), whereas the MATCH query on the FTS3 table selects only those
rows that contain "linux" as a discrete token. Both searches are
case-insensitive.
So your query will only match strings that have 'Angela' as a word (at least that is how I interpret 'discrete token').
I have a table in which there's a column of type BLOB. Another column is of type 'text'. Something like:
CREATE TABLE Tbl(TXT text, BLB blob);
Now I've inserted a few records using:
INSERT INTO Tbl(TXT) VALUES("whatever");
As you can see nothing was defined for BLB. But each time that I issue a query like:
SELECT * FROM 'Tbl' WHERE 'TXT'="whatever";
I get nothing at all without any error message or anything. My primary guess was that the problem might have something to do with BLB being null or undefined or something like that. Any ideas?
Your query should be:
SELECT * FROM Tbl WHERE TXT="whatever";
You are specifying strings for the table name and for the column. SQL lets you perform queries on values, not just tables.
My SQL query is giving error while trying to execute query:
Error:
Query input must contain at least one table or query
INSERT into Posts (PostText,TimePosted, TID)
VALUES ('My Post','2013-04-11 13:50:18',
(SELECT MAX(TID) FROM Threads AS TID))
Combine the literal fields with the select & move the alias;
INSERT into Posts (PostText,TimePosted, TID)
SELECT 'My Post','2013-04-11 13:50:18', MAX(TID) AS TID FROM Threads
You have not specified table name in your query.
There are 3 fields in your table and you are sending 3 values (Last value by select query).
But you have not written table name for main query in which data to insert.
I'm working on a small SQLite database using the Unix command line sqlite3 command tool. My schema is:
sqlite> .schema
CREATE TABLE status (id text, date integer, status text, mode text);
Now I want to set the column 'mode' to the string "Status" for all entries. However, if I type this:
sqlite> UPDATE status SET mode="Status";
Instead of setting column 'mode' to the string "Status", it sets every entry to the value that is currently in the column 'status'. Instead, if I type the following it does the expected behavior:
sqlite> UPDATE status SET mode='Status';
Is this normal behavior?
This is also a FAQ :-
My WHERE clause expression column1="column1" does not work. It causes every row of the table to be returned, not just the rows where column1 has the value "column1".
Use single-quotes, not double-quotes, around string literals in SQL. This is what the SQL standard requires. Your WHERE clause expression should read: column1='column2'
SQL uses double-quotes around identifiers (column or table names) that contains special characters or which are keywords. So double-quotes are a way of escaping identifier names. Hence, when you say column1="column1" that is equivalent to column1=column1 which is obviously always true.
http://www.sqlite.org/faq.html#q24
Yes, that's normal in SQL.
Single quotes are used for string values; double quotes are used for identifiers (like table or column names).
(See the documentation.)