Hello stackoverflow so I have a cratedb database instance with about 3 million records in my table. I am trying to run the following command.
ALTER TABLE "transactions_v2" DROP COLUMN "itemPrices";
However I end up with this error
Error!
SQLParseException[line 1:62: mismatched input 'COLUMN' expecting {'.', 'PARTITION', 'DROP'}]
Any ideas why I can't seem to drop the column?
So cratedb does not support DROP COLUMN which is why I was getting the error.
Related
I am trying to drop a table names "union" but I keep getting an error.
I am not sure who and how created that table, but nothing works on it, including describe or select.
Using "hdfs dfs -ls" outside of hive, I can see that table exists and there is data in it, but cannot drop the table.
I am assuming there may be a problem because the table is called "union" and the error I get is
"cannot recognize input near 'union'".
How can I drop the table?
to escape in hive you can use bakctick:
DROP TABLE IF EXISTS `union`;
My sqlite database has existing column named order_id in tbl_order with duplicate entries.
I am trying to remove duplicate entries and add constraint(UNIQUE) to solve this.
So I have tried following code to solve above issue.
I have checked previous and current build version to manage existing and new database.
It successfully executes first query but showing error in modify constraint.
if (previousBuildVersion < currentBuildVersion) {
FMResultSet *result = nil;
result = [self.objDB executeQuery:#"SELECT DISTINCT order_id FROM tbl_order ORDER BY order_id"];
[self.objDB executeUpdate:#"ALTER TABLE 'tbl_order' MODIFY \ 'order_id' TEXT NOT NULL UNIQUE \ ;"];
}
I am getting this error in Xcode:
[logging] near "MODIFY": syntax error
DB Error: 1 "near "MODIFY": syntax error"
Please suggest a solution to this issue as I have very less experience working with FMDB library.
Thanks in advance.
You cannot alter column in sqlite once it has been created.
Only the RENAME TABLE and ADD COLUMN variants of the ALTER TABLE command are supported. Other kinds of ALTER TABLE operations such as DROP COLUMN, ALTER COLUMN, ADD CONSTRAINT, and so forth are omitted.
Please check this link for more details :
https://www.sqlite.org/omitted.html
I am using Azure SQL in Microsoft SQL Management studio. I firstly renamed a column called ssma$rowid to ssmarowid, then I deleted this column using
ALTER TABLE "myCoolTable" DROP COLUMN "ssmarowid";
SQL management studio prompted me that the deletion was successful, but now that I try to run any UPDATE commands on my table in different columns, I get this error message:
Invalid column name 'ssma$rowid'.
If I try to edit a cell without scripting, by right-clicking my table, then Edit top 200, I get this error message:
The data in row xxx was not committed.
Error Source: .Net SqlClient Data Provider.
Error Message: Invalid column name 'ssma$rowid'
Invalid column name 'ssma$rowid'
Invalid column name 'ssma$rowid'
Correct the errors and retry or press ESC to cancel the change(s)
The column ssma$rowid does not appear in my table at all when I run a SELECT statement, and if I explicitly try to pull the column ssma$rowid or ssmarowid SQL tells me that they don't exist.
It appears that my column has been lost in the ether somewhere, where can I start searching to find my rogue column?
Ensure the ALTER TABLE states the column between brackets like this :
ALTER TABLE [myCoolTable] DROP COLUMN [ssmarowid];
i'm getting the above error when i try and run any alter table type script, even an add column script returns this error eg:
alter table up_retail add StockGroupID int null
running the above will return the above error, i have tried restarting sql, restore ansi settings etc, does anyone have any advice on what might be causing this?
UPDATE:
when i try and drop constraints as per
ALTER TABLE [dbo].[ZSeeAlso] DROP CONSTRAINT [FK_ZSeeAlso_Performers]
i get this:
Incorrect syntax near 'dbo'.
again, any ideas what would cause this?
** UPDATE 2 **
for everyone checking this is the only thing in my query window, here is my ssms:
Your query is okey , try to Use YourDB that contains the table up_retail Not Master like this :
Use YourDB
Alter Table up_retail Add StockGroupID int null
Go
after trying everything i can think and that, that was suggested in here, i basically ended up re-installing sql and that seems to have fixed. it looks like the syntax engine or sql itself became corrupt for some reason
thanks all for the suggestions
in orther to get a column similar to the mysql ENUM type, I wrote a sql query as follows
ALTER TABLE [DbName].[dbo].[MediaContent]
ADD MediaType nvarchar(50)
check(MediaType in ('audio','video','song','other'))
this worked as wished(for test): But now I want to delete this column without success. It seems like there no way to directly delete a column which has a constraint up on it.
How can I solve this issue? I want to delete this column and create another one.
here is the error message I get while the deletion
The object 'CK__MediaCont__Media__14270015' is dependent on column 'MediaType'.
ALTER TABLE DROP COLUMN MediaType failed
because one or more objects access this
column. (Microsoft SQL Server, Error: 5074)
The object referenced in the error message is the name of the constraint. You should be able to use the follow:
ALTER TABLE [DbName].[dbo].[MediaContent]
DROP CONSTRAINT CK__MediaCont__Media__14270015
You need to first drop the check constraint mentioned in the error message since that's stopping you from dropping the column. Following that you may drop the column.
Drop the constrain first then drop the column ,it will work