Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the backslash \ counted as a character in MySQL?

Tags:

database

mysql

if i have a table which has columns with fixed lenght, Will mySQL count the backslashes as characters?

Example :

people(name[10],age[3])

If i store in the name column a MySQL escaped value like : Blahblah\'s Will MySQL cut it at the quote?

Thanks

like image 875
CodeOverload Avatar asked Nov 24 '25 12:11

CodeOverload


1 Answers

No, escape characters do not add the length of char or varchar string, because escape characters are not stored at all.

CREATE TABLE a (name char(5));

INSERT INTO a VALUES ('1234567890');
INSERT INTO a VALUES ('12\'345678');

SELECT * FROM a;
+-------+
| name  |
+-------+
| 12345 | 
| 12'34 | 
+-------+
2 rows in set (0.00 sec)
like image 83
Daniel Vassallo Avatar answered Nov 26 '25 13:11

Daniel Vassallo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!