Learning how to format SQL code for readability

Formatting your SQL code for readability is vital so that you and others can quickly understand your SQL code. SQL ignores whitespace, making it easy to format for readability. You can write SQL code all on one line, but it's much easier to read if you place different parts of the SQL on separate lines. 

For example, you could write code as shown in the following example, which has all the code on one line and wraps around: 

CREATE TABLE `managerstest` (`managerkey` smallint NOT NULL,`playerid` varchar(9) NOT NULL,`yearid` year(4) NOT NULL,`teamid` char(3) NOT NULL); 

Instead, think about writing it so that it is easier to read, like the following code: 

CREATE TABLE `managerstest` 
(`managerkey` smallint NOT NULL,
`playerid` varchar(9) NOT NULL,
`yearid` year(4) NOT NULL,
`teamid` char(3) NOT NULL);
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.33.157