Failed to create table in tdengine - tdengine

I used tdengine to create table,but I have failed. My create sql is:
create table test (ts timestamp,key nchar(10),val int);
But I was failed becasue of these error:
DB error: invalid operation: invalid column name (0.000760s)
I don’t know why this error occurred. Does someone one why ? Thanks!

I think this is because that column "key" is a keyword in TDengine. So you can't create a table witch column named "key". Further more, any of the key word should not be avoid in sql.
TDengine's key word
reference the [TDengine Parameter Limits and Reserved Keywords] chapter.

Related

RedGate - Computed Column Dependent on Function Fails in Migration

We've added a new computed column to a SQL Server database table. The new computed column is dependent on a new function.
When we attempt to deploy the branch, migrations reports the error shown below.
Error: Synchronization of 'Scripts.RedGate' and 'SomeServer.SomeDb' failed:
Cannot find either column "dbo" or the user-defined function or aggregate
"dbo.IsACredit", or the name is ambiguous. Error executing the following SQL:
ALTER TABLE [dbo].[SomeTable] ADD [IsCredit] AS ([dbo].[IsACredit]([ID]))
How can we successfully deploy these needed database changes?
Thank you in advance!

SQL compilation error: invalid identifier for TIMESTAMP_NTZ(9) fields in Snowflake table

I have a table with 2 TIMESTAMP_NTZ(9) fields. When I try to add either of these to a WHERE clause I get a SQL compilation error: invalid identifier. If name either of these field in my SELECT statement I also get this error. If I perform a SELECT * the fields are available and return data.
Relatively new to Snowflake, what am I missing here?

Exporting from SQL Server to Postgres ERROR: column is of type boolean but expression is of type integer

I am using SSMS to export a table into my Postgres DB as described here. Everything is going great, the table and columns are created in Postgres, but when the data is to be loaded it errors out with the following error message:
Error 0xc020844b: Data Flow Task 1: An exception has occurred during data insertion, the message returned from the provider is: ERROR [42804] ERROR: column "XYZ" is of type boolean but expression is of type integer;
I understand the issue, but not sure how to resolve it as I do not see an option in the export wizard to change types. And if I try to create the table ahead of time and do the export I get the following error:
Error 0xc002f210: Preparation SQL Task 1: Executing the query "CREATE TABLE "ABC" (
"XYZ" i..." failed with the following error: "ERROR [42P07] ERROR: relation "ABC" already exists;
Any help would be great. Thanks ahead of time.
What I ended up doing:
Do all the steps as described in the link in my question,when you get to the point in the wizard where you select your table, after selecting your table name will appear in the next column "Destination" double click it and select the correct type for your destination.
happy coding!

I'm having trouble deciphering a MySQL error log, gotten through "forward engineer" option

Here is the error:
Executing SQL script in server
ERROR: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')
REFERENCES `mydb`.`Skill` ()
ON DELETE NO ACTION
ON UPDATE NO ACTI' at line 5
CREATE TABLE IF NOT EXISTS `mydb`.`employeeSkill` (
`idEmployee` INT NOT NULL ,
PRIMARY KEY (`idEmployee`) ,
CONSTRAINT `idSkill`
FOREIGN KEY ()
REFERENCES `mydb`.`Skill` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
SQL script execution finished: statements: 18 succeeded, 1 failed
You've mixed up the syntax for defining column constraints with defining table constraints. Inside the parens after the table name, you should have a comma-separated list of column definitions, which are of the form "column_name column_type column_constraints" where the only required element is the column name. After the first comma, though, you have PRIMARY KEY (idEmployee), which is not a column definition. (Instead, it's syntax appropriate for an ALTER TABLE command.) Check the syntax of the CREATE TABLE command here.

Cannot insert duplicate record in a table

I am trying to execute stored proc through SSIS and it gives me following error:
[Execute SQL Task] Error: Executing
the query "Exec sp1 ?" failed with
the following error: "Procedure: sp1
Line: 66 Message: Cannot insert
duplicate key row in object
'table.sq1' with unique index
'UIX_sp1_Key'.". Possible failure
reasons: Problems with the query,
"ResultSet" property not set
correctly, parameters not set
correctly, or connection not
established correctly.
Actually the stored Proc sp1 is truncating & reloading a data into a table.
I am not able to figure out where exactly its trying to insert duplicate record.
Thanks in advance.
Your data must have duplicate values across the key column(s). You could remove the primary key temporarily (or create another table with the same structure but without the definition of the primary key, but that would mean changing the stored procedure), then load the data into the table. Then use this SQL statement:
select keycol1 {,keycol2 {,keycol3} ...}, count(*)
from tablename
group by keycol1 {,keycol2 {,keycol3} ...}
having count(*) > 1
That will show you the data values that are duplicates across the key column(s).
If you are truncating the table before load, then you must have duplicate data in the source.
Examine this to see what there is. use Excel or Access or some such if needed to assist. Or drop the unique constraint then query the staging table with an aggregate query.

Resources