Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9019845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:52:12+00:00 2026-06-16T04:52:12+00:00

I have the following as a CREATE TABLE in Oracle: CREATE TABLE cs2_users (

  • 0

I have the following as a CREATE TABLE in Oracle:

CREATE TABLE cs2_users (
    empnum     varchar2(12) PRIMARY KEY,
    toolsId    varchar2(20) 
        CONSTRAINT nn_cs2_users_toolsId NOT NULL
        CONSTRAINT fk_cs2_users_users FOREIGN KEY REFERENCES users.userid,
    admin      number(1,0) DEFAULT 0
        CONSTRAINT nn_cs2_users_admin NOT NULL
        CONSTRAINT ck_cs2_users_admin (admin IN (0,1)),
    givenname  varchar2(30) NOT NULL,
    middlename varchar2(30),
    sn         varchar2(30) NOT NULL,
    mail       varchar2(50) NOT NULL
);

However it fails with this error:

ERROR at line 5:
ORA-02253: constraint specification not allowed here`

When I connect using SQL*Plus, this is the version info:

SQL*Plus: Release 11.2.0.3.0 Production on Tue Dec 18 16:38:27 2012

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:52:14+00:00Added an answer on June 16, 2026 at 4:52 am

    If you want to specify an inline constraint, that definition is separate from the definition of the column. You need to specify the type of the constraint if you are creating a CHECK constraint. And your foreign key constraint needs to specify which column you are referencing. So, for example, this will work

    SQL> create table users( userid varchar2(20) primary key );
    
    Table created.
    
    
    SQL> CREATE TABLE cs2_users (
      2      empnum     varchar2(12) PRIMARY KEY,
      3      toolsId    varchar2(20) constraint nn_cs2_users_toolsId NOT NULL,
      4          CONSTRAINT fk_cs2_users_users FOREIGN KEY(toolsId) REFERENCES users(userid),
      5      admin      number(1,0) DEFAULT 0 constraint nn_cs2_users_admin NOT NULL,
      6          CONSTRAINT ck_cs2_users_admin CHECK(admin IN (0,1)),
      7      givenname  varchar2(30) NOT NULL,
      8      middlename varchar2(30),
      9      sn         varchar2(30) NOT NULL,
     10      mail       varchar2(50) NOT NULL
     11  );
    
    Table created.
    

    though it seems odd that the toolsId references the userId column from users. It would seem more likely that you would want the toolsId column to reference the toolsId column from a tools table or that you would want to name the column something like userId if you want to reference the userId column from users. But then I’d question why you have a separate cs2_users column rather than simply putting this information in the users table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table: CREATE TABLE [dbo].[Data] ( [Id] UNIQUEIDENTIFIER NOT NULL, [Data]
I have the following tables CREATE TABLE `files` ( `fileid` int(11) NOT NULL AUTO_INCREMENT,
I have the following tables: create table TableA ( Id int primary key identity,
I have the following table: CREATE TABLE [dbo].[Tree]( [AutoID] [int] IDENTITY(1,1) NOT NULL, [Category]
I have a table CREATE TABLE STUDENT ( ID INTEGER PRIMARY KEY, FIRSTNAME VARCHAR2(1024
I have the following table CREATE TABLE `prod_prices` ( `id` varchar(32) COLLATE utf8_unicode_ci NOT
I have the following table: CREATE TABLE TEST(ID TINYINT NULL, COL1 CHAR(1)) INSERT INTO
I have the following table: CREATE TABLE IF NOT EXISTS `customer_list` ( `id` INT
I have two tables like so: create table doi ( id number primary key
I have a table in Oracle 10 with following structure Create Table Bookmarks( BOOKMARKID

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.