Interview Question in SQL Server Indexing


 

Interview Question :: Database Error HELP PLZ



When i try to creat a database i get this error


Error
SQL query:

CREATE TABLE `donavons_Testdatabase`.`Kelly` (
`price` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL ,
`dis` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL ,
INDEX ( `price` , `dis` )
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_bin

MySQL said:

#1170 - BLOB/TEXT column 'price' used in key specification without a key length

Can you help me fix it. Or give me step by step setup on the host monster mysql database.

PS if someone that knows what they are doing could IM ME that would be asome! THANK YOU SO MUCH FOR ALL YOUR HELP
Answers to "Database Error HELP PLZ "
RE: Database Error HELP PLZ ?

First, what you are doing is to create a table.



Whle I'm not famliar with MySql, I work with both MsSql and Oracle and in either of those a blob/Clob/text type column cannot be used as an index. You must instead used a char,nchar or varchar,varchar2, nvarchar field with a declared max length. (further, in MSSql, I do not believe that a (n)varchar(MAX) can be used either).



I would bet that this is the problem.
 
Vote for this answer ::  
RE: Database Error HELP PLZ ?

While I agree that adding a field length to 'price' may solve your immediate problem, I see a more serious design flaw by defining the column that way to begin with. Why did you not define 'price' as some variety of numeric (probably like DECIMAL (5,2))? That way, you would be able to do computations on the field without messy extraction and conversion issues.
 
Vote for this answer ::  
RE: Database Error HELP PLZ ?

im not so sure but i think you don't have the length of the column price. you just have to add a text size or better yet use a varchar

it should look like this:



'price varchar(20) NOT NULL default '',



try this im me if it does'nt work..






 
Vote for this answer ::  
Update Alert Setting