Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

MySql problem

Name: Anonymous 2010-07-22 6:10

Hi /prog/,

A MySQL noob needs some help here. I tried searching everywhere but it seems I cannot formulate my search expression correctly(English is not my first language). So the problem is. I want to limit the values that can be inserted in a column to certain possibilities. For example: I have a column phone_type and I want the only possible values there to be Work, Mobile, General and Fax. Any ideas? Sorry if this is too simple!

Name: Anonymous 2010-07-22 6:24

English is not my first language
that's no excuse for being lazy.
http://lmgtfy.com/?q=mysql+enum+type&l=1
now, back to /b/, please.

Name: Anonymous 2010-07-22 6:36

>>2
He didn't post anything /b/-like. Note how he said "noob" instead of "n*wfag". Perhaps he should go back to stackoverflow, please.

Name: Anonymous 2010-07-22 6:49

Perhaps he should Google for SQL CHECK constraints.

Name: Anonymous 2010-07-22 6:53

maybe you should only post if you're actually increasing the thread quality

Name: Anonymous 2010-07-22 7:07

>>4
MySQL doesn't have those.
The real answer is not to use MySQL, but he'll probably think someone telling him about the ENUM type is more useful.

Name: Anonymous 2010-07-22 8:34

Two MiceSquirrel threads in a day?

Well now I've seen everything!

Name: Anonymous 2010-07-22 12:15

>>3
Sigh.
Fuck off, ``faggot''.

Name: Anonymous 2010-07-22 18:22

Easy way:
Put all your phone types in a single-column new table, create a primary key for it and add a foreign key constraint to the phone_type column.

Hard way:
Write a trigger function spitting an error if a user tries to put in a non-allowed value.

Hard way, God mode:
If a user tries again to insert the illegal value, do a DROP USER

Name: Anonymous 2010-07-22 18:34

>>9
If a user tries again to insert the illegal value, do a DROP USER
Do I know you?

Name: Anonymous 2010-07-22 19:01

How are you interfacing the database?

Name: Anonymous 2010-07-22 19:03

>>9
Easy way:
Put all your phone types in a single-column new table, create a primary key for it and add a foreign key constraint to the phone_type column.

You misspelled ``Incompetent way''.
The generous interpretation would be to assume you're trying to work around MySQL's inability to have regular constraints on columns, but MySQL also doesn't have foreign keys, so you're an idiot either way.

Name: Anonymous 2010-07-22 19:36

>>12
Why don't you just go fuck yourself

Name: Anonymous 2010-07-22 19:42

>>13
Back to /pr/, please.

Name: Anonymous 2010-07-22 20:05

>>12
I thought they got fkeys a couple of years back. Or was that transactions? You know, I just about lost it when MySQL was getting lots of press for supporting features I was using in PostgreSQL ten years earlier.

Name: Anonymous 2010-07-22 21:01

>>15
MySQL recognizes the keyword, but doesn't enforce the constraints unless you're using the InnoDB backend, and the default is MyISAM which is just incompetent and useless. So technically it supports them, but in practicality it really doesn't.

Name: Anonymous 2010-07-22 21:06

>>15
Well, it depends on your point of view.
MyISAM, which is the default engine MySQL uses, supports none of these things and never will. InnoDB supports a few features MyISAM doesn't (including foreign keys, I thought), but is a buggy, unstable piece of shit that's even more likely to fuck up your data than MyISAM; its only purpose is to serve as something MySQL fanboys can point to when sensible people point out MySQL is a joke of a RDBMS.

Name: Anonymous 2010-07-23 1:40

>>16,17
Isn't there some third engine that no one really talks about? I seem to recall reading something about another one besides those two.

Name: Anonymous 2010-07-23 8:09

>>12
I'm glad I hadn't dealt with any FailSQL DB so far. How can a RDBMS be useful without foreign key integrity?

Name: Anonymous 2011-01-31 20:03

<-- check em dubz

Name: Anonymous 2011-05-26 4:29

MySQL IS the problem

Name: Anonymous 2011-05-26 4:53

>>17
Are you suggesting that MyISAM doesn't support foreign key constraints? Because that, good sir, is utter bullshit.

That being said, I wouldn't recommend using InnoDB for anyone - simply enabling this module will increase MySQL's memory usage by at least 100 MB. Something like that can't be any good!

Name: Anonymous 2011-05-26 12:51

How can you guys possibly know so much about MySQL without realizing how far behind it is? Every new feature is added to MySQL 10 years later than every other RDBMS.

Don't change these.
Name: Email:
Entire Thread Thread List