Sybase ASE issue dropping unique constraint - sybase

When dropping a unique constraint both using Sybase Central or iSQL, the drop statement shown is as follows;
alter table user_database.dbo.table_name drop constraint contraint_name
But execution fails with different errors, like this:
If constraint name is between single quotes, the command returns:
Incorrect syntax near the word 'constraint'
If constraint name is between square braquets, the command returns:
The identifier that starts with '[constraint_name' is too long. Maximum lenght is 28.
If constraint name is written alone, the command returns
Incorrect syntax near '.'
I'm 'sa' user and I've tried issuing commands from both master and user_database. Any suggestions?

Don't use any quotes or brackets, and pls post the full final statement. Also try leaving off the db name (make sure you are in that database).

Related

Snowflake DROP TABLE table_name(...)

Why the below syntax does not error out:
CREATE TABLE a1 AS SELECT 1 a;
TRUNCATE TABLE a1(sth);
-- SQL compilation error: syntax error line 1 at position 17 unexpected '('.
DROP TABLE a1(sth);
-- A1 successfully dropped.
-- here I would expect an error
Both TRUNCATE TABLE and DROP TABLE take parameter <name>
Specifies the identifier for the table to drop. If the identifier contains spaces, special characters, or mixed-case characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive (e.g. "My Object").
Is there a special behaviour for table_name(...)?
In "drop table", the table name does not accept any parameters so it should not accept any parentheses. Please open a ticket and report this bug to Snowflake.

Incorrect syntax near 'FK_dbo.SalesOrderLineTasks_dbo.Events_Event_ID'

When I try and run
alter table salesorderlinetasks drop constraint
'FK_dbo.SalesOrderLineTasks_dbo.Events_Event_ID'
this command in Sql Server Management Studio, I get an error.
Incorrect syntax near 'FK_dbo.SalesOrderLineTasks_dbo.Events_Event_ID'.
What should I do?
It should contain double quotes instead of single quotes.
Use no quotes:
alter table salesorderlinetasks drop constraint
FK_dbo.SalesOrderLineTasks_dbo.Events_Event_ID
Quotes delimit literal text, but alter requires an entity (which is not a text string but a plain entity name).

ORA-00911: invalid character error while truncating table

I have a table that name is _VERSION_HISTORY I got ORA-00911 error while truncating this table. Oracle allow the name start with underscore(_) but throws an error while truncating it. Is it a silly mistake?
Oracle does not allow database object names to start with an underscore:
SQL> create table _T34 (col1 number);
create table _T34 (col1 number)
*
ERROR at line 1:
ORA-00911: invalid character
SQL>
So you must have used double quotes when creating that table:
SQL> create table "_T34" (col1 number);
Table created.
SQL>
Having done that once you must use double quotes whenever you reference that object?
SQL> truncate table "_T34";
Table truncated.
SQL>
So is it "a silly mistake"? Yes, but alas on your part (or whoever decided on using double-quotes to circumvent Oracle's naming conventions). Find out more.
It seems like you have tried to execute SQL statement with a special charter in it. I don't think it is to do with the truncate command. You might just replace the truncate with a simple Select and test this scenario. Note that the special character might appear as white space due to the font you are using.

cannot add new column (Incorrect syntax near the keyword 'COLUMN')

When I run this
ALTER TABLE agency
ADD COLUMN single_word varchar(100)
I get
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'COLUMN'.
I tried removing the COLUMN but still same problem.
For TSQL Flavor try this syntax:
ALTER TABLE agents
ADD [associated department] varchar(100)
I have same issue when running that query on HeidiSQL. The solution is simple, change the query to be like this:
ALTER TABLE "agency"
ADD "single_word" varchar(100)
just remove "COLUMN" keyword.
Depending on the database software you are using, if you want to have a space in the column name (which I would recommend against), you will have to escape it.
For example, in MySQL, you would use the backtick (the character to the left of the number 1 at the top of the keyboard) :
ALTER TABLE agents
ADD COLUMN `associated department` varchar(100);
For SQL Server, you can use [], and for most other DBMSes, the double-quote (") will escape identifiers

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.

Resources