---- Start
Many people cannot figure out what is carriage return and line feed. The following briefly introduces the origins and differences of these two concepts.
Before the advent of a computer, there was a kind of thing called a telex typewriter that allowed 10 characters per second. But there is a problem, that is, when a line breaks a line, it takes 0.2 seconds, just two characters. If a new character is passed in the 0.2 s, the character will be lost. As a result, the developers thought of a way to solve this problem, that is, adding two end characters after each line. One is "enter", which tells the typewriter to position the print head on the left boundary, and the other is "line feed", which tells the typewriter to move the paper down one line. This is the source of "line feed" and "Carriage Return". They can also be seen in their English names.
Later, computers were invented, and these two concepts were invented on computers. At that time, memory was very expensive. Some scientists thought it would be too waste to add two characters at the end of each line. Just add one character. As a result, there were differences. In Unix systems, each line ends with "<line feed>", that is, "\ n". In Windows systems, each line ends with "<line feed> <press enter> ", that is, "\ n \ r". In MAC systems, the end of each line is "<press enter> ". One direct consequence is that if a file in UNIX/MAC is opened in windows, all the text will be changed to a line; if a file in Windows is opened in UNIX/MAC, A ^ m symbol may be added at the end of each line.
So what if we want to store some text in the database, and this text contains line breaks and carriage returns? See the following code:
Values 'Hello everyone' | CHR (10) | CHR (13) | 'I'm wave'
The aboveCHR FunctionIt is used to convert the ASCII code into characters, the line feed ASCII code is 10, and the carriage return ASCII code is 13. It is not just a carriage return or line feed. If you want to enter any other special characters, you can use the above methodCHR Function.
----ASCII code table
---- For more information, see:DB2 SQL
----Statement: indicate the source for reprinting.
---- Last updated on 2009.11.27
---- Written by shangbo on 2009.10.24
---- End