Ask the Expert

Creating a table with a MUL column

What is the syntax to create a table in which a field will have MUL as the key?

Requires Free Membership to View

MUL is displayed when you use the DESCRIBE statement to get information on a table. MUL simply means that an index allows non-unique values to be present. Even if a column has a UNQIUE key, it can still be designated MUL if NULL values are allowed (since you could have multiple NULL values in the column).

So to create a table that will have a column that is MUL, just declare it to have a non-unique index, or a unique index that allows NULL values:

mysql> CREATE TABLE mul_test(
   -> mul_column INT UNSIGNED,
   -> INDEX(mul_column)
   -> );
Query OK, 0 rows affected (0.01 sec)

mysql> DESCRIBE mul_test;
+------------+------------------+------+-----+---------+-------+
| Field      | Type             | Null | Key | Default | Extra |
+------------+------------------+------+-----+---------+-------+
| mul_column | int(10) unsigned | YES  | MUL | NULL    |       |
+------------+------------------+------+-----+---------+-------+
1 row in set (0.00 sec) 

This was first published in November 2004

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: