ORA-00907: missing right parenthesis in sql

Kailash Sahu 141 Reputation points
2022-03-06T20:47:43.637+00:00
   SQL> create table customer(  
    2  CUST long varchar(5));  

Getting a error :- ORA-00907: missing right parenthesis

I want to 5 CHARACTER LONG of CU180455-yy.jpgST

SQL Server Other
{count} votes

Accepted answer
  1. Naomi Nosonovsky 8,431 Reputation points
    2022-03-09T04:28:18.24+00:00

    In SQL Server (and other databases) you can have composite primary key (e.g. more than one column can be a primary key). You would use CONSTRAINT keyword, e.g. for example:

        CREATE TABLE [dbo].[Depositor]
                    (
                        cust_no int NOT NULL,
    account_no int NOT NULL,
    
                              CONSTRAINT [PK_Depositor]
                              PRIMARY KEY CLUSTERED ([cust_no], [account_no])
                              WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON
                                    , ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80
                                   ) ON [PRIMARY]
                    ) ON [PRIMARY];
    

    Foreign key constraints are normally created using the following syntax:

    ALTER TABLE [dbo].[Depositor] WITH CHECK
            ADD
                CONSTRAINT [FK_Depositor_Cust_No]
                FOREIGN KEY ([cust_no])
                REFERENCES [dbo].[Customer] ([cust_no]);
    

5 additional answers

Sort by: Most helpful
  1. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2022-03-07T02:27:28.517+00:00

    Hi @Kailash Sahu ,

    SQL server general tag on MS Q&A forum talking about MS SQL server tech issues. It seems your issue is related to Oracle SQL. Please post your issue on Oracle Forum or post issue to Oracle tag on Stack overflow forum. People there will give you a better help.

    If I misunderstood, please let me know.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

  2. Sreeju Nair 12,666 Reputation points
    2022-03-07T08:39:13.367+00:00

    I believe, the problem lies in the SQL Query. Can you try the following.

    create table customer( 
    CUST long varchar(5)
    );
    

  3. Sreeju Nair 12,666 Reputation points
    2022-03-07T11:41:39.82+00:00

    Try this

    create table customer( 
         CUST varchar2(5)
         );
    
    0 comments No comments

  4. Naomi Nosonovsky 8,431 Reputation points
    2022-03-07T16:10:41.777+00:00

    You probably wanted:

    create table customer (
        CUST_NO char(5) constraint chk_firstLetter CHECK (CUST_NO LIKE 'C%')); 
    

    This would compile, but you may want to also add other columns according to your specifications.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.