-1
CREATE TABLE tblaccid2(
aAid TEXT(200) NOT NULL,
aEmail TEXT(88),
Password TEXT(32),
Status CHAR(5),
AccType CHAR(10),
PRIMARY KEY(aAid)
)
  #1170 - BLOB/TEXT column 'aAid' used in key specification without a key length

pls give a example that can work with 1 or 2 primary key with 2 not primary key , primary key must be text or tinytext datatype

Barmar
  • 741,623
  • 53
  • 500
  • 612
J.WCT
  • 92
  • 9
  • 1
    text type has no length attribute. besides this, setting a text as primary key is insane -)) – marmeladze Sep 19 '17 at 13:11
  • 1
    Possible duplicate of [MySQL error: key specification without a key length](https://stackoverflow.com/questions/1827063/mysql-error-key-specification-without-a-key-length) – GrumpyCrouton Sep 19 '17 at 13:24

1 Answers1

0

From the documentation on MySQL Indexes:

When you index a BLOB or TEXT column, you must specify a prefix length for the index.

So you need:

PRIMARY KEY (aAid(200))

However, there's little reason to be using TEXT for such short strings. Just change all your TEXT columns to VARCHAR. See Difference between VARCHAR and TEXT in mysql

Barmar
  • 741,623
  • 53
  • 500
  • 612