why i am getting Error when modify table column clickhouse - clickhouse

I have a table with column action LowCardinality(String),
but I want to change this column to -> action Nullable(String) and I am getting this error:
Code: 473, e.displayText() = DB::Exception: READ locking attempt on
"glassbox.beacon_event" has timed out! (120000ms) Possible deadlock
avoided. Client should retry.: While executing Columns (version
20.4.2.9 (official build))
Also the client is stuck (tabix).
If i will run this command like this, it works:
alter table test modify column action String
alter table test modify column action Nullable(String)
Why can't I run with one command?
alter table test modify column action Nullable(String)

probably it's a bug. Try Ch version 20.6

Related

Drop multiple tables at once in ClickHouse

I'm trying to drop a few tables at once on a ClickHouse cluster. As example:
DROP TABLE IF EXISTS default.log_null, default.null_view
I get the error:
Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 39 (','): , default.null_view. Expected one of: NO DELAY, end of query, INTO OUTFILE, SETTINGS, ON, FORMAT, SYNC (version 21.3.13.9 (official build))
What is the correct syntax if such action is supported?

Inserting into a populated table

I am working on a oracle project, but I have come across this error and can't figure it out. So i have created a table "Drugs" and I have 4 columns. They are as follows: (D_id, D_name, D_Date_of_Exp, D_price). I had populated the first 3 columns and forgot to populate the 'D_price' column with values.
So, now when I tried to insert data into it again:
insert into drugs(d_id, d_price) values(50, 400)
gave me this error:
ORA-00001: unique constraint (PARTH.SYS_C007100) violated
I know what causes the error above, my question is, how can I get around that error and insert the prices that match with the 'D_id' in my table.
So, I tried this:
insert into drugs(d_price) values(400)
where d_id = 50;
gave me this error: ORA-00933: SQL command not properly ended
Still lost. Any help would be great, thank you.
As your table already populated, and you missed D_PRICE to populate while inserting data into table. Now It's time to update the record, use the SQL like:
update drugs set d_price = 400
where d_id = 50;

Oracle Alter command to rename existing Column errorring

alter table tablename rename column zl_divn_nbr to div_loc_nbr;
Error while executing the above statement. Please help.
SQL Error: ORA-54032: column to be renamed is used in a virtual column expression
54032. 0000 - "column to be renamed is used in a virtual column expression"
*Cause: Attempted to rename a column that was used in a virtual column
expression.
*Action: Drop the virtual column first or change the virtual column
expression to eliminate dependency on the column to be renamed
Run the following SQL query in your database using the table name mentioned in the error message. For example, in the error message shown in this article, the table name is 'tablename'. Note that whilst the table name appears in lower case in the error message, it may be upper case in your DB. This query is case sensitive so if you receive no results, check whether the table name is upper case inside your database.
SELECT COLUMN_NAME, DATA_DEFAULT, HIDDEN_COLUMN
FROM USER_TAB_COLS
WHERE TABLE_NAME = 'tablename';
Before proceeding, make sure the Bitbucket Server process is not running. If Extended Statistics has been enabled, contact your database administrator to have them drop the Extended Statistics metadata from the table, and proceed with your upgrade. If you wish to enable Extended Statistics again after the upgrade you may do so, however be aware that you may need to repeat this process again for subsequent upgrades otherwise you risk running into this issue again.
Removing columns created by Extended Statistics requires using an in-build stored procedure,
DBMS_STATS.DROP_EXTENDED_STATS().
Usage of this stored procedure is covered further in ORA-54033 and the Hidden Virtual Column Mystery, and looks similar to the following:
EXEC DBMS_STATS.DROP_EXTENDED_STATS(ownname=>'<YOUR_DB_USERNAME>', tabname=>'tablename', extension=>'("PR_ROLE", "USER_ID", "PR_APPROVED")')
References
Database Upgrade Eror: column to be rename
Thanks.
Probably, you have such a table :
CREATE TABLE tablename(
id NUMBER,
zl_divn_nbr NUMBER,
zl_divn_percent NUMBER GENERATED ALWAYS AS (ROUND(zl_divn_nbr/100,2)) VIRTUAL
);
where zl_divn_nbr column is used for a computation for virtual(zl_divn_percent) column.
To rename zl_divn_nbr, all referenced virtual columns to this column should be removed, and may be created later.
The syntax for defining a virtual column is this :
column_name [datatype] [GENERATED ALWAYS] AS (expression) [VIRTUAL]
Since version 11 R1, we have this property.
ALTER TABLE rename column to
In the case of tables with virtual or 'group extension columns' the above
statement returns an error before Oracle 12cR2. For Oracle 12cR2 or newer versions the above statement runs fine cause 'renaming column' command is decoupled from the group extension aspect.

Can't modify table column character set in Oracle

I want to change character set so I used code as below:
ALTER TABLE MY_MST CONVERT TO CHARACTER SET sjis;
But I got error looks like this:
Error starting at line : 3 in command -
ALTER TABLE MY_MST CONVERT TO CHARACTER SET sjis
Error report -
SQL Error: ORA-01735: invalid ALTER TABLE option
I also tried ALTER TABLE MY_MST MODIFY ...., same error, what can I do? I am working in Oracle SQL Developer

expecting KW_EXCHANGE near 'table' in alter exchange partition

I am dealing with a table in hive which does not have partitions and with input format as textinputformat. This is not an external table and I create it using "Create table as select" template.
I use the alter table statement to rename the table as given below:
ALTER TABLE testdb.temptable RENAME TO testdb.newtable;
I get the following error:
Error: Error while compiling statement: FAILED: ParseException line 1:32 mismatched input 'RENAME' expecting KW_EXCHANGE near 'temptable' in alter exchange partition (state=42000,code=40000)
Closing: org.apache.hive.jdbc.HiveConnection
I see it is a bug in hive. I use the version:
Hive 0.12.0-cdh5.1.4
How do i go about fixing this issue. Thanks in advance for the help!
It's not exactly a bug, just a side effect of Open Source when it's done by a motley crew of people all around the world with no "product owner" and no incentives to use a common programming style (or run extensive regression tests, or <insert your complaint here>).
Aaaaaaah, now that it's said, I feel better... Let's get to the point.
In HiveQL the alter command does not use the same semantics as create or select; specifically, you cannot use the "ALTER DATABASE.TABLE" notation. If you try, then the HQL parser just fails with a queer error message, as you can see by yourself.
That's the way it is. You must type a use command first, then your alter command with just the table name. Yes, it sucks. But that's the way it is. And I see no reason why it should improve any time soon.
[Update Jun-2017] looks like ALTER finally supports the DB.TABLE syntax, on recent Cloudera distro (tested on CDH 5.10 with Hive 1.1.0 - but since they usually include a number of back-ports in their distro, maybe it's a feature of Hive 1.2+)
I have similar error message it is gone after using alternative syntax, selecting schema and reference table by the short name:
USE mydb;
ALTER TABLE mytable RECOVER PARTITIONS;

Resources