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

  • SEARCH
  • Home
  • 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 5938055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:37:49+00:00 2026-05-22T15:37:49+00:00

I am wanting to have a label column ( VARCHAR ) and I want

  • 0

I am wanting to have a label column (VARCHAR) and I want it to be unique, but when I try to create the table it seems to be throwing an error. Can a unique constraint only be used in conjunction with an INTEGER or will it work with other datatypes as well. The error I am getting is (ERRNO 150)

CREATE TABLE IF NOT EXISTS `user`(
user_id INT  NOT NULL    AUTO_INCREMENT  PRIMARY KEY,
username    VARCHAR(50) NOT NULL,
`password`  VARCHAR(255) NOT NULL
);

CREATE TABLE IF NOT EXISTS `element`(
element_id  INT NOT NULL    AUTO_INCREMENT PRIMARY KEY,
label   VARCHAR(5) NOT NULL DEFAULT '',
parent_id   INT NULL,
user_id INT NOT NULL,
created_on  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
edited_on   TIMESTAMP NOT NULL,
UNIQUE(label),
KEY element_1 (label),
CONSTRAINT FK_element_1 FOREIGN KEY (user_id) REFERENCES `user` (user_id),
CONSTRAINT FK_element_2 FOREIGN KEY (parent_id) REFERENCES `element` (element_id)
);
  • 1 1 Answer
  • 2 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-05-22T15:37:50+00:00Added an answer on May 22, 2026 at 3:37 pm

    The only way I can have this error, if the first table is created with MyISAM engine and the second (tried to be created) with InnoDB.

    Check the definition of the created table user, using:

    SHOW CREATE TABLE user ;
    

    If that’s the case, drop it and recreate it with:

    CREATE TABLE IF NOT EXISTS `user`(
    user_id INT  NOT NULL    AUTO_INCREMENT  PRIMARY KEY,
    username    VARCHAR(50) NOT NULL,
    `password`  VARCHAR(255) NOT NULL
    )
     ENGINE = InnoDB ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been wanting to make a circular preloader in my iPhone app, but
I have a file server and wanting to optimize it the best I can,
I have a valid reason for wanting to do this, but it's a long
I am wanting to have a view table that aggregates rows from four tables.
I want to allow my site visitors to create a customizable and printable label,
I am wanting to have a typedef within in a typedef and wonder if
I'm wanting to have a strongly typed user control that accepts the class PaginatedList<T>
I am wanting to have the EXACT same data across two WordPress sites that
EDIT: See my answer below--> I am wanting to have a view that when
I'm using scrollto, and I'm wanting to have a class added when it scrolls

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.