enable compression in TimeScaleDB hypertable - invalid column name - sql

When I try and enable compression on my TimeScale DB hypertable using this query:
ALTER TABLE public."Session" SET (
timescaledb.compress,
timescaledb.compress_segmentby = 'AssetId'
);
I get the following error:
ERROR: column "assetid" does not exist
HINT: The timescaledb.compress_segmentby option must reference a valid column.
SQL state: 42601
All I can say is that AssetId is a valid column in the Session table. I'm not sure what else to try.
Is anybody familiar with this error and could offer a solution please?
Thank you

Sometimes Postgresql requires the case-sensitive version of the name and therefore the column name was to be quoted.
That said, all you do is to double-quote the name inside the passed string:
timescaledb.compress_segmentby = '"AssetId"'

Related

Can I use question marks in SQLite table column name?

When I try to create a table with the following as a column name: "Admin?" in my SQLite Database, I get a SQL error saying:
SQL error or missing database (near "?": syntax error)
Here is my SQL statement:
CREATE TABLE test (admin? TEXT PRIMARY KEY);
I am assuming I cannot have question marks inside column names, but I cannot find any documentation about it. If this is the issue, is there any workaround here, or a better solution? Also, I am creating the table from Kotlin code, so I am not sure if that has any effect on it.
Escape the column name:
CREATE TABLE test ("admin?" TEXT PRIMARY KEY);

Facing an error when trying to insert the data in database using db2?

I'm trying to insert a row in the table by using below code but it is throwing an error. can anyone help me out to solve the error?
Thanks in advance!!
db2 "Insert into TARIFF_PRODUCT_ATTRIBUTES values (409499, 'ADDITION_SMS_TEMPLATE', 'IDSSMS1')";
Error is :
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0204N "DB2EAI2.TARIFF_PRODUCT_ATTRIBUTES" is an undefined name.
SQLSTATE=42704
Common causes of SQL0204N in Db2:
spelling mistake in the object name
object does not exist in the currently connected Db2 database
object exists in current database but in a different schema than your current default schema (so you must qualify the name with the correct schema-name).
mixed case table name (Db2 will always uppercase unquoted object names, so if the object is Tariff_Product_Attributes then use double-quotes around the name in the SQL to allow Db2 to find the object).
There are other less common causes , see the documentation for the complete list.

Trying to create a new column, get #1064 error

I've been using phpMyAdmin to manage my db without any problem, but today I ran into this error if I try to add any column by using the interface to any table of any database:
ALTER TABLE `testing` ADD `faaa` INT NOT NULL AFTER ;
#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 '' at line 1
But if I add the column via SQL command in phpMyAdmin, this time by removing AFTER, the column is added without any problem.
I'm still inexperience with phpMyAdmin, so I guess I must have missed a mandatory field to fill when creating a new column in the interface. Can anyone shed a light on this for me?
AFTER column_name is used to designate which column in the table you want to insert the new column after. You're providing the AFTER without telling it which column you want the new column to be inserted behind. If you don't care about the order of the columns in your table, omit the AFTER, and the new column will be inserted at the end of the column list.
You have no column name after the AFTER statement, so the phpMyAdmin doesn't know where it should be put. Whether it's you forgetting to select the column or a phpMyAdmin bug, I have no idea because for adding a new column, the only required fields are the name and type, which you have.

postgres database column name not recognized

I'm using postgresql database, in a table, I have a column named date.
The problem occurs when I try making some operations with this column (date).
For example:
create index tg_index ON table_replay using btree(date);
here is my error:
ERROR: column "date" does not exist
****** Error ******
ERROR: column "date" does not exist SQL state: 42703
PS: I cannot change this column name because this is a big database so i need many years to perform any change. Thanks for understanding.
Change your column name from date to another such as date because date is a reserved word. You can easily achieve this by using alter commmand. Using alter command dosen't take too much time because alter command only affects the table structure reather than the data of the table. alter command have no concern with the data of the table.
http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html says date is a reserved keyword. You can try quoting it. That may not work.
I agree witht he above comment - use of plain keywords that have a generic sense is generally a bad practice - column names should help to describe the purpose of the column.

copy one field from table to another field in the same table

I used this query to copy one full column from the same table:
UPDATE 'content_type_chapter'
SET 'field_chapternumbersort2_value' = 'field_chapternumbersort_value'
But I have received this error.
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 ''content_type_chapter' SET 'field_chapternumbersort2_value'='field_chapternumber' at line 1
What could be wrong, I'm unable to get it right.
Single-quotes are for strings.
Try backticks instead, e.g.:
UPDATE
`content_type_chapter`
SET
`field_chapternumbersort2_value` = `field_chapternumbersort_value`
The backticks aren't strictly necessary, though.
Just leave the quotes off your field names, otherwise it thinks you are giving it strings