What is the SQL MODE in MYSQL (or any RDBMS)? Also what is the best option to have for the SQL MODE and Why?
If i could have a layman explanation with a example it would be great!
Thank you in advance 😉
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
The SQL mode affects how MySQL behaves in certain situations. For example, it affects what happens if you try to insert overlong content into a text type column. Let’s say you have a column like
CHAR(10) CHARACTER SET ascii NOT NULL, and you try to insert'abcdef abcdef'. That’s 13 characters, which is too long. If the current SQL mode includesSTRICT_TRANS_TABLESorSTRICT_ALL_TABLES, MySQL will not insert the value but will give you an error message. If neither of these is on, then MySQL will truncate the string to 10 characters, i.e.'abcdef abc', and insert that.There are lots of other behaviours that are affected by the SQL mode. That was just an example.
I personally use
TRADITIONAL, which is shorthand for, well, the link given by dcp will tell you. Basically, it makes MySQL less forgiving when you send it invalid input, which I find preferable because if I send MySQL something that’s not valid I’d rather know about it, rather than have MySQL fudge it and not tell me it’s done so.