{"id":20358,"date":"2024-10-16T09:00:00","date_gmt":"2024-10-16T08:00:00","guid":{"rendered":"https:\/\/www.dbvis.com\/?p=20358"},"modified":"2024-08-23T09:39:27","modified_gmt":"2024-08-23T08:39:27","slug":"how-to-format-sql-query-strings","status":"publish","type":"post","link":"https:\/\/www.dbvis.com\/thetable\/how-to-format-sql-query-strings\/","title":{"rendered":"How To Format SQL Query Strings"},"content":{"rendered":"\n<div class=\"wp-block-group has-black-background-color has-background is-layout-constrained wp-block-group-is-layout-constrained\" style=\"padding-top:40px;padding-bottom:20px\" data-block-type=\"core\">\n<div class=\"wp-block-stackable-columns alignfull stk-block-columns stk-block stk-05153d0\" data-block-id=\"05153d0\"><style>.stk-05153d0{max-width:672px !important;margin-right:auto !important;margin-left:auto !important}<\/style><div class=\"stk-row stk-inner-blocks stk-block-content stk-content-align stk-05153d0-column alignwide\">\n<div class=\"wp-block-stackable-column stk-block-column stk-column stk-block stk-0ae88f8\" data-v=\"4\" data-block-id=\"0ae88f8\"><style>.stk-0ae88f8-container{max-width:600px !important;margin-right:auto !important;margin-left:auto !important}<\/style><div class=\"stk-column-wrapper stk-block-column__content stk-container stk-0ae88f8-container stk--no-background stk--no-padding\"><div class=\"stk-block-content stk-inner-blocks stk-0ae88f8-inner-blocks\">\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-68a9012 stk-subtitle\" data-block-id=\"68a9012\"><style>.stk-68a9012 .stk-block-text__text{font-size:14px !important;color:#7B7B7B !important;font-family:\"jetbrainsmono\",Sans-serif !important}@media screen and (max-width:1199px){.stk-68a9012 .stk-block-text__text{font-size:14px !important}}<\/style><p class=\"stk-block-text__text has-text-color\">intro<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-a8f1ca9\" data-block-id=\"a8f1ca9\"><style>.stk-a8f1ca9 .stk-block-text__text{font-size:16px !important;color:#ffffff !important;font-family:\"authenticsans\",Sans-serif !important}@media screen and (max-width:1199px){.stk-a8f1ca9 .stk-block-text__text{font-size:16px !important}}<\/style><p class=\"stk-block-text__text has-text-color has-white-color\">Let's look at how to format SQL query strings and find out why doing it in your database client makes everything easier and faster.<\/p><\/div>\n\n\n<section class=\"thetableTools thetableTools__wrapper\">\n    <div class=\"thetableTools thetableTools__container\">\n        <span class=\"thetableTools thetableTools__subhead\">Tools used in the tutorial<\/span>\n        <div class=\"thetableTools thetableTools__table\">\n            <div class=\"thetableTools thetableTools__divider\"><\/div>\n            <div class=\"thetableTools thetableTools__headers\">\n                <span class=\"thetableTools thetableTools__header thetableTools__header--name\">Tool<\/span>\n                <span class=\"thetableTools thetableTools__header thetableTools__header--description\">Description<\/span>\n                <span class=\"thetableTools thetableTools__header thetableTools__header--link\">Link<\/span>\n            <\/div>\n                                <div class=\"thetableTools thetableTools__divider\"><\/div>\n                    <div class=\"thetableTools thetableTools__tool\">\n                        <div class=\"thetableTools thetableTools__col thetableTools__col--name\">\n                            <span class=\"thetableTools thetableTools__content thetableTools__content--icon\"><img decoding=\"async\" width=\"40\" height=\"40\" src=\"https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/dbvis_logo_nopadding-42x42.png\" class=\"attachment-40x40 size-40x40\" alt=\"Dbvisualizer\" srcset=\"https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/dbvis_logo_nopadding-42x42.png 42w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/dbvis_logo_nopadding.png 50w\" sizes=\"(max-width: 40px) 100vw, 40px\" \/><\/span>\n                            <span class=\"thetableTools thetableTools__content thetableTools__content--name\">DBVISUALIZER<\/span>\n                        <\/div>\n                        <div class=\"thetableTools thetableTools__col thetableTools__col--description\">\n                            <span class=\"thetableTools thetableTools__content thetableTools__content--description\">TOP RATED DATABASE MANAGEMENT TOOL AND SQL CLIENT<\/span>\n                        <\/div>\n                        <div class=\"thetableTools thetableTools__col thetableTools__col--link\">\n                            <span class=\"thetableTools thetableTools__content thetableTools__content--link\">\n                                <a href=\"\/download\/\" class=\"ctaBlock ctaBlock__ctaLink ctaBlock__ctaLink--internal\">DOWNLOAD<\/a>\n                            <\/span>\n                        <\/div>\n                    <\/div>                        <div class=\"thetableTools thetableTools__divider\"><\/div>\n        <\/div>\n    <\/div>\n<\/section>\n<\/div><\/div><\/div>\n<\/div><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group alignfull has-background is-layout-constrained wp-block-group-is-layout-constrained\" style=\"background-color:#f9f9e1\" data-block-type=\"core\">\n<div class=\"wp-block-stackable-columns alignfull stk-block-columns stk-block stk-66c8395881a68\" data-block-id=\"66c8395881a68\"><style>.stk-66c8395881a68{margin-top:40px !important;margin-bottom:0px !important}.stk-66c8395881a68-column{max-width:672px !important;justify-content:left !important}<\/style><div class=\"stk-row stk-inner-blocks has-text-align-left stk-block-content stk-content-align stk-66c8395881a68-column stk--flex alignfull\">\n<div class=\"wp-block-stackable-column stk-block-column stk-column stk-block stk-66c8395881a69\" data-v=\"4\" data-block-id=\"66c8395881a69\"><div class=\"stk-column-wrapper stk-block-column__content stk-container stk-66c8395881a69-container stk--no-background stk--no-padding\"><div class=\"stk-block-content stk-inner-blocks stk-66c8395881a69-inner-blocks\">\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c839377a033\" data-block-id=\"stk66c839377a033\"><p class=\"stk-block-text__text\">SQL queries can become long and messy, making it harder for developers to understand what is going on. If you have come across a poorly formatted query at least once, you are in the right place! With the right tool, you can easily format SQL query strings.<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c839377a045\" data-block-id=\"stk66c839377a045\"><p class=\"stk-block-text__text\">In this article, you will take a look at SQL formatting, understanding how it works, why it is important, and how to apply it in a powerful database client.<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c839377a048\" data-block-id=\"stk66c839377a048\"><p class=\"stk-block-text__text\">Let's dive in!<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-stk66c839377a104\" id=\"stk66c839377a104\" data-block-id=\"stk66c839377a104\"><h2 class=\"stk-block-heading__text\">What Does It Mean to Format an SQL Query?<\/h2><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c839377a109\" data-block-id=\"stk66c839377a109\"><p class=\"stk-block-text__text\">Formatting a query means rewriting its SQL code to improve readability. This process is usually performed by a formatter, which follows the three-step procedure below to format SQL query strings:<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-icon-list stk-block-icon-list stk-block stk-66c839377a19a\" data-block-id=\"66c839377a19a\"><style>.stk-66c839377a19a .stk-block-icon-list-item__content{gap:4px !important;align-items:baseline !important}.stk-66c839377a19a{--stk-icon-height:16px !important}<\/style><div class=\"stk-block-icon-list__ol stk-block-icon-list--column\"><ol class=\"stk-block-icon-list__group\">\n<li class=\"wp-block-stackable-icon-list-item stk-block-icon-list-item stk-block stk-d309ecc\" data-block-id=\"d309ecc\"><div class=\"stk-block-icon-list-item__content\"><span class=\"stk-block-icon-list-item__marker\" aria-hidden=\"true\"><\/span><span class=\"stk-block-icon-list-item__text\">Analyze the input SQL code and identify its constituent parts, such as literals, keywords, space characters, and punctuation.<\/span><\/div><\/li>\n\n\n\n<li class=\"wp-block-stackable-icon-list-item stk-block-icon-list-item stk-block stk-c656513\" data-block-id=\"c656513\"><div class=\"stk-block-icon-list-item__content\"><span class=\"stk-block-icon-list-item__marker\" aria-hidden=\"true\"><\/span><span class=\"stk-block-icon-list-item__text\">Apply a set of rules, best practices, and conventions to rewrite each element of SQL code according to a specific standard or style guide.<\/span><\/div><\/li>\n\n\n\n<li class=\"wp-block-stackable-icon-list-item stk-block-icon-list-item stk-block stk-8430a38\" data-block-id=\"8430a38\"><div class=\"stk-block-icon-list-item__content\"><span class=\"stk-block-icon-list-item__marker\" aria-hidden=\"true\"><\/span><span class=\"stk-block-icon-list-item__text\">Reassemble the formatted elements into a structured and cohesive SQL statement.<\/span><\/div><\/li>\n<\/ol><\/div><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c839377a1c5\" data-block-id=\"stk66c839377a1c5\"><p class=\"stk-block-text__text\">To better understand what that means, consider the following unformatted query:<\/p><\/div>\n<\/div><\/div><\/div>\n<\/div><\/div>\n<\/div>\n\n\n\n<div id=\"pre-wrapper-66c8395881a73\" class=\"wp-block-group has-dbvis-light-yellow-background-color has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"padding-top:0px\" data-block-type=\"core\"><section class=\"codeBlock codeBlock__wrapper\">\n    <div class=\"codeBlock codeBlock__copyWrapper\">\n        <a class=\"codeBlock codeBlock__copyCodeButton\">Copy<\/a>\n        <pre class=\"codeBlock codeBlock__container\">\n        <div class=\"codeBlock codeBlock__codeBlockNumber\"><\/div>\n        <code class=\"codeBlock codeBlock__linesContainer\">\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">1<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">SELECT<\/span> FIRST_NAME, LAST_NAME, SALARY, <span class=\"text-product-orange\">CASE<\/span> <span class=\"text-product-orange\">WHEN<\/span> SALARY &gt; 10000 <span class=\"text-product-orange\">THEN<\/span> <span class=\"text-brand-green\">'High'<\/span> <span class=\"text-product-orange\">WHEN<\/span> SALARY <span class=\"text-product-orange\">BETWEEN<\/span> 5000 <span class=\"text-product-orange\">AND<\/span> 999 <span class=\"text-product-orange\">THEN<\/span> <span class=\"text-brand-green\">'Midlevel'<\/span> <span class=\"text-product-orange\">ELSE<\/span> <span class=\"text-brand-green\">'Low'<\/span> <span class=\"text-product-orange\">END<\/span> <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"Income Level\"<\/span>, <span class=\"text-product-orange\">CASE<\/span> DEPARTMENT_ID <span class=\"text-product-orange\">WHEN<\/span> 40 <span class=\"text-product-orange\">THEN<\/span> <span class=\"text-brand-green\">'Administration'<\/span> <span class=\"text-product-orange\">WHEN<\/span> 20 <span class=\"text-product-orange\">THEN<\/span> <span class=\"text-brand-green\">'Sales Related'<\/span> <span class=\"text-product-orange\">ELSE<\/span> <span class=\"text-brand-green\">'Other'<\/span> <span class=\"text-product-orange\">END<\/span> <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"Special Departments\"<\/span> <span class=\"text-product-orange\">FROM<\/span> EMPLOYEES;<\/span>\n                <\/span>\n                    <\/code>\n    <\/pre>\n    <\/div>\n<\/section>\n<\/div>\n\n\n\n<div class=\"wp-block-group alignfull has-background is-layout-constrained wp-block-group-is-layout-constrained\" style=\"background-color:#f9f9e1\" data-block-type=\"core\">\n<div class=\"wp-block-stackable-columns alignfull stk-block-columns stk-block stk-66c8395881a75\" data-block-id=\"66c8395881a75\"><style>.stk-66c8395881a75{margin-top:0px !important;margin-bottom:0px !important}.stk-66c8395881a75-column{max-width:672px !important;justify-content:left !important}<\/style><div class=\"stk-row stk-inner-blocks has-text-align-left stk-block-content stk-content-align stk-66c8395881a75-column stk--flex alignfull\">\n<div class=\"wp-block-stackable-column stk-block-column stk-column stk-block stk-66c8395881a76\" data-v=\"4\" data-block-id=\"66c8395881a76\"><div class=\"stk-column-wrapper stk-block-column__content stk-container stk-66c8395881a76-container stk--no-background stk--no-padding\"><div class=\"stk-block-content stk-inner-blocks stk-66c8395881a76-inner-blocks\">\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c839377a293\" data-block-id=\"stk66c839377a293\"><p class=\"stk-block-text__text\">The equivalent formatted SQL query is:<\/p><\/div>\n<\/div><\/div><\/div>\n<\/div><\/div>\n<\/div>\n\n\n\n<div id=\"pre-wrapper-66c8395881a78\" class=\"wp-block-group has-dbvis-light-yellow-background-color has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"padding-top:0px\" data-block-type=\"core\"><section class=\"codeBlock codeBlock__wrapper\">\n    <div class=\"codeBlock codeBlock__copyWrapper\">\n        <a class=\"codeBlock codeBlock__copyCodeButton\">Copy<\/a>\n        <pre class=\"codeBlock codeBlock__container\">\n        <div class=\"codeBlock codeBlock__codeBlockNumber\"><\/div>\n        <code class=\"codeBlock codeBlock__linesContainer\">\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">1<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">SELECT<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">2<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    FIRST_NAME,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">3<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    LAST_NAME,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">4<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    SALARY,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">5<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    <span class=\"text-product-orange\">CASE<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">6<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">WHEN<\/span> SALARY &gt; 10000<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">7<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">THEN<\/span> <span class=\"text-brand-green\">'High'<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">8<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">WHEN<\/span> SALARY <span class=\"text-product-orange\">BETWEEN<\/span> 5000 <span class=\"text-product-orange\">AND<\/span> 999<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">9<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">THEN<\/span> <span class=\"text-brand-green\">'Midlevel'<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">10<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">ELSE<\/span> <span class=\"text-brand-green\">'Low'<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">11<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    <span class=\"text-product-orange\">END<\/span> <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"Income Level\"<\/span>,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">12<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    <span class=\"text-product-orange\">CASE<\/span> DEPARTMENT_ID<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">13<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">WHEN<\/span> 40<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">14<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">THEN<\/span> <span class=\"text-brand-green\">'Administration'<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">15<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">WHEN<\/span> 20<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">16<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">THEN<\/span> <span class=\"text-brand-green\">'Sales Related'<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">17<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">ELSE<\/span> <span class=\"text-brand-green\">'Other'<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">18<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    <span class=\"text-product-orange\">END<\/span> <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"Special Departments\"<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">19<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">FROM<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">20<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    EMPLOYEES;<\/span>\n                <\/span>\n                    <\/code>\n    <\/pre>\n    <\/div>\n<\/section>\n<\/div>\n\n\n\n<div class=\"wp-block-group alignfull has-background is-layout-constrained wp-block-group-is-layout-constrained\" style=\"background-color:#f9f9e1\" data-block-type=\"core\">\n<div class=\"wp-block-stackable-columns alignfull stk-block-columns stk-block stk-66c8395881a79\" data-block-id=\"66c8395881a79\"><style>.stk-66c8395881a79{margin-top:0px !important;margin-bottom:0px !important}.stk-66c8395881a79-column{max-width:672px !important;justify-content:left !important}<\/style><div class=\"stk-row stk-inner-blocks has-text-align-left stk-block-content stk-content-align stk-66c8395881a79-column stk--flex alignfull\">\n<div class=\"wp-block-stackable-column stk-block-column stk-column stk-block stk-66c8395881a7a\" data-v=\"4\" data-block-id=\"66c8395881a7a\"><div class=\"stk-column-wrapper stk-block-column__content stk-container stk-66c8395881a7a-container stk--no-background stk--no-padding\"><div class=\"stk-block-content stk-inner-blocks stk-66c8395881a7a-inner-blocks\">\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c839377a29f\" data-block-id=\"stk66c839377a29f\"><p class=\"stk-block-text__text\">As you can see, the resulting query is also more maintainable and easier to understand.<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c839377a2a1\" data-block-id=\"stk66c839377a2a1\"><p class=\"stk-block-text__text\"><em>In most cases, formatting an SQL query boils down to capitalizing keywords, separating different clauses clearly, and rewriting parts the code using consistent indentation.<\/em><\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-stk66c839377a2aa\" id=\"stk66c839377a2aa\" data-block-id=\"stk66c839377a2aa\"><h2 class=\"stk-block-heading__text\">Benefits of Formatting a Query in SQL<\/h2><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c839377a2ac\" data-block-id=\"stk66c839377a2ac\"><p class=\"stk-block-text__text\">The top three benefits of formatting SQL queries are:<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-icon-list stk-block-icon-list stk-block stk-66c839377a2ae\" data-block-id=\"66c839377a2ae\"><style>.stk-66c839377a2ae .stk-block-icon-list-item__content{gap:4px !important;align-items:baseline !important}.stk-66c839377a2ae{--stk-icon-height:16px !important}<\/style><div class=\"stk-block-icon-list__ol stk-block-icon-list--column\"><ol class=\"stk-block-icon-list__group\">\n<li class=\"wp-block-stackable-icon-list-item stk-block-icon-list-item stk-block stk-3ac5011\" data-block-id=\"3ac5011\"><div class=\"stk-block-icon-list-item__content\"><span class=\"stk-block-icon-list-item__marker\" aria-hidden=\"true\"><\/span><span class=\"stk-block-icon-list-item__text\"><strong>Enhanced readability<\/strong>: Well-formatted SQL queries are much easier to read. Clear formatting helps to quickly understand the structure and logic of the query, reducing the cognitive load on developers.<\/span><\/div><\/li>\n\n\n\n<li class=\"wp-block-stackable-icon-list-item stk-block-icon-list-item stk-block stk-10c1257\" data-block-id=\"10c1257\"><div class=\"stk-block-icon-list-item__content\"><span class=\"stk-block-icon-list-item__marker\" aria-hidden=\"true\"><\/span><span class=\"stk-block-icon-list-item__text\"><strong>Improved team collaboration<\/strong>: Standardized query formatting ensures that all SQL code in a codebase adheres to the same style. This facilitates code reviews and collaboration, especially when the development team consists of several developers. It also helps new team members become familiar with the code more quickly and makes the queries look more professional.<\/span><\/div><\/li>\n\n\n\n<li class=\"wp-block-stackable-icon-list-item stk-block-icon-list-item stk-block stk-2a50808\" data-block-id=\"2a50808\"><div class=\"stk-block-icon-list-item__content\"><span class=\"stk-block-icon-list-item__marker\" aria-hidden=\"true\"><\/span><span class=\"stk-block-icon-list-item__text\"><strong>Easier debugging and maintenance<\/strong>: In a consistently formatted SQL query, it is easier to spot errors and inconsistencies at a glance. When the query structure is clear, identifying syntax errors, logical flaws or performance bottlenecks becomes quicker. That also simplifies the process of <a href=\"https:\/\/www.dbvis.com\/thetable\/how-to-work-with-sql-query-optimization\/\">SQL query optimization<\/a>.<\/span><\/div><\/li>\n<\/ol><\/div><\/div>\n\n\n\n<div class=\"wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-stk66c839377a2c5\" id=\"stk66c839377a2c5\" data-block-id=\"stk66c839377a2c5\"><h2 class=\"stk-block-heading__text\">Automatically Format SQL Queries in Your Database Client<\/h2><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c839377a2c7\" data-block-id=\"stk66c839377a2c7\"><p class=\"stk-block-text__text\">As explored in our <a href=\"https:\/\/www.dbvis.com\/thetable\/sql-formatter-definition-and-best-tools\/\">SQL formatter guide<\/a>, there are numerous tools and approaches to formatting SQL queries. The most intuitive, logical, and time-saving solution is to format SQL query strings directly in your database client.<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c839377a2cd\" data-block-id=\"stk66c839377a2cd\"><p class=\"stk-block-text__text\">First, you need a database client that comes with SQL formatting capabilities, such as <a href=\"https:\/\/www.dbvis.com\/\">DbVisualizer<\/a>. This tool equips you with everything you need to build, manage, and deal with state-of-the-art database technologies.<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c839377a2d2\" data-block-id=\"stk66c839377a2d2\"><p class=\"stk-block-text__text\"><a href=\"https:\/\/www.dbvis.com\/download\/\">Download DbVisualizer<\/a>, execute the installer, and follow the installation wizard. Once set up, launch the application and then open the SQL Commander tab:<\/p><\/div>\n<\/div><\/div><\/div>\n<\/div><\/div>\n<\/div>\n\n\n\n<div id=\"img-wrapper-66c8395881a80\" class=\"wp-block-group has-dbvis-light-yellow-background-color has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"padding-top:20px\" data-block-type=\"core\"><section class=\"thetableImage thetableImage__wrapper\">\n    <div class=\"thetableImage thetableImage__container thetableImage__container--dark thetableImage__container--wide thetableImage__container--shadow\">\n        <div class=\"thetableImage thetableImage__imageWrapper thetableImage__imageWrapper--dark thetableImage__imageWrapper--wide thetableImage__imageWrapper--shadow\">\n            <div class=\"thetableImage thetableImage__imageContainer thetableImage__imageContainer--dark thetableImage__imageContainer--wide thetableImage__imageContainer--shadow\">\n                <img decoding=\"async\" width=\"1024\" height=\"547\" src=\"https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716297669702_UntitledProject-1024x547.gif\" class=\"attachment-large size-large\" alt=\"Open an SQL Commander tab\" srcset=\"https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716297669702_UntitledProject-1024x547.gif 1024w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716297669702_UntitledProject-300x160.gif 300w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716297669702_UntitledProject-768x410.gif 768w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716297669702_UntitledProject-1300x694.gif 1300w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716297669702_UntitledProject-42x22.gif 42w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/>            <\/div>\n        <\/div>\n                    <span class=\"thetableImage thetableImage__imageCaption thetableImage__imageCaption--dark thetableImage__imageCaption--wide\">Open an SQL Commander tab<\/span>\n            <\/div>\n<\/section>\n<\/div>\n\n\n\n<div class=\"wp-block-group alignfull has-background is-layout-constrained wp-block-group-is-layout-constrained\" style=\"background-color:#f9f9e1\" data-block-type=\"core\">\n<div class=\"wp-block-stackable-columns alignfull stk-block-columns stk-block stk-66c8395881a82\" data-block-id=\"66c8395881a82\"><style>.stk-66c8395881a82{margin-top:0px !important;margin-bottom:0px !important}.stk-66c8395881a82-column{max-width:672px !important;justify-content:left !important}<\/style><div class=\"stk-row stk-inner-blocks has-text-align-left stk-block-content stk-content-align stk-66c8395881a82-column stk--flex alignfull\">\n<div class=\"wp-block-stackable-column stk-block-column stk-column stk-block stk-66c8395881a83\" data-v=\"4\" data-block-id=\"66c8395881a83\"><div class=\"stk-column-wrapper stk-block-column__content stk-container stk-66c8395881a83-container stk--no-background stk--no-padding\"><div class=\"stk-block-content stk-inner-blocks stk-66c8395881a83-inner-blocks\">\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c839417ca0e\" data-block-id=\"stk66c839417ca0e\"><p class=\"stk-block-text__text\">Here, you can write any SQL query in the <a href=\"https:\/\/www.dbvis.com\/supported-databases\/\">dozens of dialects supported by DbVisualizer<\/a>. For example, write the following, messy, and unformatted SQL Server script that involves some <a href=\"https:\/\/www.dbvis.com\/thetable\/crud-advanced-insert-queries\/\">CRUD statements<\/a>:<\/p><\/div>\n<\/div><\/div><\/div>\n<\/div><\/div>\n<\/div>\n\n\n\n<div id=\"pre-wrapper-66c8395881a84\" class=\"wp-block-group has-dbvis-light-yellow-background-color has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"padding-top:0px\" data-block-type=\"core\"><section class=\"codeBlock codeBlock__wrapper\">\n    <div class=\"codeBlock codeBlock__copyWrapper\">\n        <a class=\"codeBlock codeBlock__copyCodeButton\">Copy<\/a>\n        <pre class=\"codeBlock codeBlock__container\">\n        <div class=\"codeBlock codeBlock__codeBlockNumber\"><\/div>\n        <code class=\"codeBlock codeBlock__linesContainer\">\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">1<\/span>\n                    <span class=\"codeBlock codeBlock__line\">-- Basic <span class=\"text-product-orange\">SELECT<\/span> example, with Sub-<span class=\"text-product-orange\">SELECT<\/span> and <span class=\"text-product-orange\">JOIN<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">2<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">SELECT<\/span> e.LAST_NAME <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"Last Name\"<\/span>, e.FIRST_NAME <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"First Name\"<\/span>, d.DEPARTMENT_NAME <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"Department\"<\/span>, e.SALARY <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"Salary\"<\/span>, e.SALARY + e.SALARY * e.COMMISSION_PCT, e.COMMISSION_PCT * 100 || <span class=\"text-brand-green\">'%'<\/span>, ROUND(e.SALARY \/ ( <span class=\"text-product-orange\">SELECT<\/span> MAX(SALARY) <span class=\"text-product-orange\">FROM<\/span> HR.EMPLOYEES), 2) * 100 <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"Percentage of Max\"<\/span> <span class=\"text-product-orange\">FROM<\/span> HR.EMPLOYEES e <span class=\"text-product-orange\">INNER JOIN<\/span> HR.DEPARTMENTS d <span class=\"text-product-orange\">ON<\/span> ( e.DEPARTMENT_ID = d.DEPARTMENT_ID) <span class=\"text-product-orange\">WHERE<\/span> d.DEPARTMENT_ID <span class=\"text-product-orange\">IN<\/span> (10, 20, 90, 210) <span class=\"text-product-orange\">AND<\/span> e.SALARY &gt; 3000;<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">3<\/span>\n                    <span class=\"codeBlock codeBlock__line\">-- <span class=\"text-product-orange\">JOIN<\/span> example, with <span class=\"text-product-orange\">GROUP BY<\/span>, <span class=\"text-product-orange\">HAVING<\/span> and <span class=\"text-product-orange\">ORDER BY<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">4<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">SELECT<\/span> <span class=\"text-product-orange\">COUNT<\/span>(d.DEPARTMENT_NAME) <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"Departments per Location\"<\/span>, c.COUNTRY_NAME, l.STATE_PROVINCE <span class=\"text-product-orange\">FROM<\/span> DEPARTMENTS d <span class=\"text-product-orange\">INNER JOIN<\/span> LOCATIONS l <span class=\"text-product-orange\">ON<\/span> d.LOCATION_ID = l.LOCATION_ID <span class=\"text-product-orange\">INNER JOIN<\/span> COUNTRIES c <span class=\"text-product-orange\">USING<\/span> (COUNTRY_ID) <span class=\"text-product-orange\">GROUP BY<\/span> c.COUNTRY_NAME, l.STATE_PROVINCE <span class=\"text-product-orange\">HAVING<\/span> <span class=\"text-product-orange\">COUNT<\/span>(d.DEPARTMENT_NAME) &gt; 1 <span class=\"text-product-orange\">ORDER BY<\/span> 2, 3, 1;<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">5<\/span>\n                    <span class=\"codeBlock codeBlock__line\">-- <span class=\"text-product-orange\">UPDATE<\/span> example<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">6<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">UPDATE<\/span> EMPLOYEES <span class=\"text-product-orange\">SET<\/span> COMMISSION_PCT = 10 <span class=\"text-product-orange\">WHERE<\/span> COMMISSION_PCT = 0 <span class=\"text-product-orange\">AND<\/span> SALARY &lt; 5000;<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">7<\/span>\n                    <span class=\"codeBlock codeBlock__line\">-- <span class=\"text-product-orange\">INSERT<\/span> example<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">8<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">INSERT INTO<\/span> EMPLOYEES ( FIRST_NAME, LAST_NAME ) <span class=\"text-product-orange\">VALUES<\/span> ( <span class=\"text-brand-green\">'Roger'<\/span>, <span class=\"text-brand-green\">'Bjarevall'<\/span> );<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">9<\/span>\n                    <span class=\"codeBlock codeBlock__line\">-- <span class=\"text-product-orange\">DELETE<\/span> example<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">10<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">DELETE<\/span> <span class=\"text-product-orange\">FROM<\/span> EMPLOYEES <span class=\"text-product-orange\">WHERE<\/span> HIRE_DATE &lt; to_timestamp(<span class=\"text-brand-green\">'1900-01-10'<\/span>, <span class=\"text-brand-green\">'RR-MM-DD'<\/span>);<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">11<\/span>\n                    <span class=\"codeBlock codeBlock__line\">-- <span class=\"text-product-orange\">CREATE TABLE<\/span> example<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">12<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">CREATE TABLE<\/span> DEPARTMENTS ( DEPARTMENT_ID NUMBER(4) <span class=\"text-product-orange\">NOT NULL<\/span>, DEPARTMENT_NAME VARCHAR2(30) <span class=\"text-product-orange\">NOT NULL<\/span>, MANAGER_ID NUMBER(6), LOCATION_ID NUMBER(4), <span class=\"text-product-orange\">CONSTRAINT<\/span> DEPT_ID_PK <span class=\"text-product-orange\">PRIMARY KEY<\/span> (DEPARTMENT_ID), <span class=\"text-product-orange\">CONSTRAINT<\/span> DEPT_LOC_FK <span class=\"text-product-orange\">FOREIGN KEY<\/span> (LOCATION_ID) <span class=\"text-product-orange\">REFERENCES<\/span> <span class=\"text-brand-green\">\"LOCATIONS\"<\/span> (<span class=\"text-brand-green\">\"LOCATION_ID\"<\/span>), <span class=\"text-product-orange\">CONSTRAINT<\/span> DEPT_MGR_FK <span class=\"text-product-orange\">FOREIGN KEY<\/span> (MANAGER_ID) <span class=\"text-product-orange\">REFERENCES<\/span> <span class=\"text-brand-green\">\"EMPLOYEES\"<\/span> (<span class=\"text-brand-green\">\"EMPLOYEE_ID\"<\/span>), <span class=\"text-product-orange\">CONSTRAINT<\/span> DEPT_NAME_NN <span class=\"text-product-orange\">CHECK<\/span> (<span class=\"text-brand-green\">\"DEPARTMENT_NAME\"<\/span> <span class=\"text-product-orange\">IS NOT NULL<\/span>) );<\/span>\n                <\/span>\n                    <\/code>\n    <\/pre>\n    <\/div>\n<\/section>\n<\/div>\n\n\n\n<div class=\"wp-block-group alignfull has-background is-layout-constrained wp-block-group-is-layout-constrained\" style=\"background-color:#f9f9e1\" data-block-type=\"core\">\n<div class=\"wp-block-stackable-columns alignfull stk-block-columns stk-block stk-66c8395881a86\" data-block-id=\"66c8395881a86\"><style>.stk-66c8395881a86{margin-top:0px !important;margin-bottom:0px !important}.stk-66c8395881a86-column{max-width:672px !important;justify-content:left !important}<\/style><div class=\"stk-row stk-inner-blocks has-text-align-left stk-block-content stk-content-align stk-66c8395881a86-column stk--flex alignfull\">\n<div class=\"wp-block-stackable-column stk-block-column stk-column stk-block stk-66c8395881a87\" data-v=\"4\" data-block-id=\"66c8395881a87\"><div class=\"stk-column-wrapper stk-block-column__content stk-container stk-66c8395881a87-container stk--no-background stk--no-padding\"><div class=\"stk-block-content stk-inner-blocks stk-66c8395881a87-inner-blocks\">\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c839417ca6f\" data-block-id=\"stk66c839417ca6f\"><p class=\"stk-block-text__text\">This wall of SQL code will now become a well-formatted SQL query. Right-click on the code editing canvas and select the \u201cFormat SQL &gt; Format Buffer\u201d option to format it:<\/p><\/div>\n<\/div><\/div><\/div>\n<\/div><\/div>\n<\/div>\n\n\n\n<div id=\"img-wrapper-66c8395881a88\" class=\"wp-block-group has-dbvis-light-yellow-background-color has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"padding-top:20px\" data-block-type=\"core\"><section class=\"thetableImage thetableImage__wrapper\">\n    <div class=\"thetableImage thetableImage__container thetableImage__container--dark thetableImage__container--wide thetableImage__container--shadow\">\n        <div class=\"thetableImage thetableImage__imageWrapper thetableImage__imageWrapper--dark thetableImage__imageWrapper--wide thetableImage__imageWrapper--shadow\">\n            <div class=\"thetableImage thetableImage__imageContainer thetableImage__imageContainer--dark thetableImage__imageContainer--wide thetableImage__imageContainer--shadow\">\n                <img decoding=\"async\" width=\"1024\" height=\"547\" src=\"https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716299761120_UntitledProject-1024x547.gif\" class=\"attachment-large size-large\" alt=\"Formatting the entire query\" srcset=\"https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716299761120_UntitledProject-1024x547.gif 1024w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716299761120_UntitledProject-300x160.gif 300w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716299761120_UntitledProject-768x410.gif 768w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716299761120_UntitledProject-1300x694.gif 1300w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716299761120_UntitledProject-42x22.gif 42w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/>            <\/div>\n        <\/div>\n                    <span class=\"thetableImage thetableImage__imageCaption thetableImage__imageCaption--dark thetableImage__imageCaption--wide\">Formatting the entire query<\/span>\n            <\/div>\n<\/section>\n<\/div>\n\n\n\n<div class=\"wp-block-group alignfull has-background is-layout-constrained wp-block-group-is-layout-constrained\" style=\"background-color:#f9f9e1\" data-block-type=\"core\">\n<div class=\"wp-block-stackable-columns alignfull stk-block-columns stk-block stk-66c8395881a8a\" data-block-id=\"66c8395881a8a\"><style>.stk-66c8395881a8a{margin-top:0px !important;margin-bottom:0px !important}.stk-66c8395881a8a-column{max-width:672px !important;justify-content:left !important}<\/style><div class=\"stk-row stk-inner-blocks has-text-align-left stk-block-content stk-content-align stk-66c8395881a8a-column stk--flex alignfull\">\n<div class=\"wp-block-stackable-column stk-block-column stk-column stk-block stk-66c8395881a8b\" data-v=\"4\" data-block-id=\"66c8395881a8b\"><div class=\"stk-column-wrapper stk-block-column__content stk-container stk-66c8395881a8b-container stk--no-background stk--no-padding\"><div class=\"stk-block-content stk-inner-blocks stk-66c8395881a8b-inner-blocks\">\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c8394cbc94f\" data-block-id=\"stk66c8394cbc94f\"><p class=\"stk-block-text__text\">The resulting formatted SQL query will be as follows:<\/p><\/div>\n<\/div><\/div><\/div>\n<\/div><\/div>\n<\/div>\n\n\n\n<div id=\"pre-wrapper-66c8395881a8c\" class=\"wp-block-group has-dbvis-light-yellow-background-color has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"padding-top:0px\" data-block-type=\"core\"><section class=\"codeBlock codeBlock__wrapper\">\n    <div class=\"codeBlock codeBlock__copyWrapper\">\n        <a class=\"codeBlock codeBlock__copyCodeButton\">Copy<\/a>\n        <pre class=\"codeBlock codeBlock__container\">\n        <div class=\"codeBlock codeBlock__codeBlockNumber\"><\/div>\n        <code class=\"codeBlock codeBlock__linesContainer\">\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">1<\/span>\n                    <span class=\"codeBlock codeBlock__line\">-- Basic <span class=\"text-product-orange\">SELECT<\/span> example, with Sub-<span class=\"text-product-orange\">SELECT<\/span> and <span class=\"text-product-orange\">JOIN<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">2<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">SELECT<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">3<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    e.LAST_NAME           <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"Last Name\"<\/span>,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">4<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    e.FIRST_NAME          <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"First Name\"<\/span>,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">5<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    d.DEPARTMENT_NAME     <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"Department\"<\/span>,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">6<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    e.SALARY              <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"Salary\"<\/span>,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">7<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    e.SALARY + e.SALARY * e.COMMISSION_PCT,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">8<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    e.COMMISSION_PCT * 100 || <span class=\"text-brand-green\">'%'<\/span>,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">9<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    ROUND(e.SALARY \/<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">10<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    (   <span class=\"text-product-orange\">SELECT<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">11<\/span>\n                    <span class=\"codeBlock codeBlock__line\">            MAX(SALARY)<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">12<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">FROM<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">13<\/span>\n                    <span class=\"codeBlock codeBlock__line\">            HR.EMPLOYEES), 2) * 100 <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"Percentage of Max\"<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">14<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">FROM<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">15<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    HR.EMPLOYEES e<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">16<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">INNER JOIN<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">17<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    HR.DEPARTMENTS d<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">18<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">ON<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">19<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    (<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">20<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        e.DEPARTMENT_ID = d.DEPARTMENT_ID)<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">21<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">WHERE<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">22<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    d.DEPARTMENT_ID <span class=\"text-product-orange\">IN<\/span> (10,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">23<\/span>\n                    <span class=\"codeBlock codeBlock__line\">                        20,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">24<\/span>\n                    <span class=\"codeBlock codeBlock__line\">                        90,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">25<\/span>\n                    <span class=\"codeBlock codeBlock__line\">                        210)<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">26<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">AND<\/span> e.SALARY &gt; 3000;<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">27<\/span>\n                    <span class=\"codeBlock codeBlock__line\">-- <span class=\"text-product-orange\">JOIN<\/span> example, with <span class=\"text-product-orange\">GROUP BY<\/span>, <span class=\"text-product-orange\">HAVING<\/span> and <span class=\"text-product-orange\">ORDER BY<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">28<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">SELECT<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">29<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    <span class=\"text-product-orange\">COUNT<\/span>(d.DEPARTMENT_NAME) <span class=\"text-product-orange\">AS<\/span> <span class=\"text-brand-green\">\"Departments per Location\"<\/span>,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">30<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    c.COUNTRY_NAME,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">31<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    l.STATE_PROVINCE<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">32<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">FROM<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">33<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    DEPARTMENTS d<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">34<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">INNER JOIN<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">35<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    LOCATIONS l<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">36<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">ON<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">37<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    d.LOCATION_ID = l.LOCATION_ID<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">38<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">INNER JOIN<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">39<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    COUNTRIES c<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">40<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">USING<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">41<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    (COUNTRY_ID)<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">42<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">GROUP BY<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">43<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    c.COUNTRY_NAME,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">44<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    l.STATE_PROVINCE<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">45<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">HAVING<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">46<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    <span class=\"text-product-orange\">COUNT<\/span>(d.DEPARTMENT_NAME) &gt; 1<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">47<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">ORDER BY<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">48<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    2,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">49<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    3,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">50<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    1;<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">51<\/span>\n                    <span class=\"codeBlock codeBlock__line\">-- <span class=\"text-product-orange\">UPDATE<\/span> example<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">52<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">UPDATE<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">53<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    EMPLOYEES<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">54<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">SET<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">55<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    COMMISSION_PCT = 10<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">56<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">WHERE<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">57<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    COMMISSION_PCT = 0<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">58<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">AND<\/span> SALARY &lt; 5000;<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">59<\/span>\n                    <span class=\"codeBlock codeBlock__line\">-- <span class=\"text-product-orange\">INSERT<\/span> example<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">60<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">INSERT INTO<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">61<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    EMPLOYEES<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">62<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    (<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">63<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        FIRST_NAME,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">64<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        LAST_NAME<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">65<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    )<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">66<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    <span class=\"text-product-orange\">VALUES<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">67<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    (<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">68<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-brand-green\">'Roger'<\/span>,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">69<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-brand-green\">'Bjarevall'<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">70<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    );<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">71<\/span>\n                    <span class=\"codeBlock codeBlock__line\">-- <span class=\"text-product-orange\">DELETE<\/span> example<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">72<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">DELETE<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">73<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">FROM<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">74<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    EMPLOYEES<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">75<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">WHERE<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">76<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    HIRE_DATE &lt; to_timestamp(<span class=\"text-brand-green\">'1900-01-10'<\/span>, <span class=\"text-brand-green\">'RR-MM-DD'<\/span>);<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">77<\/span>\n                    <span class=\"codeBlock codeBlock__line\">-- <span class=\"text-product-orange\">CREATE TABLE<\/span> example<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">78<\/span>\n                    <span class=\"codeBlock codeBlock__line\"><span class=\"text-product-orange\">CREATE TABLE<\/span><\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">79<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    DEPARTMENTS<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">80<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    (<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">81<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        DEPARTMENT_ID   NUMBER(4) <span class=\"text-product-orange\">NOT NULL<\/span>,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">82<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        DEPARTMENT_NAME VARCHAR2(30) <span class=\"text-product-orange\">NOT NULL<\/span>,<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">83<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        MANAGER_ID      NUMBER(6),<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">84<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        LOCATION_ID     NUMBER(4),<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">85<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">CONSTRAINT<\/span> DEPT_ID_PK <span class=\"text-product-orange\">PRIMARY KEY<\/span> (DEPARTMENT_ID),<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">86<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">CONSTRAINT<\/span> DEPT_LOC_FK <span class=\"text-product-orange\">FOREIGN KEY<\/span> (LOCATION_ID) <span class=\"text-product-orange\">REFERENCES<\/span> <span class=\"text-brand-green\">\"LOCATIONS\"<\/span> (<span class=\"text-brand-green\">\"LOCATION_ID\"<\/span>),<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">87<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">CONSTRAINT<\/span> DEPT_MGR_FK <span class=\"text-product-orange\">FOREIGN KEY<\/span> (MANAGER_ID) <span class=\"text-product-orange\">REFERENCES<\/span> <span class=\"text-brand-green\">\"EMPLOYEES\"<\/span> (<span class=\"text-brand-green\">\"EMPLOYEE_ID\"<\/span>),<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">88<\/span>\n                    <span class=\"codeBlock codeBlock__line\">        <span class=\"text-product-orange\">CONSTRAINT<\/span> DEPT_NAME_NN <span class=\"text-product-orange\">CHECK<\/span> (<span class=\"text-brand-green\">\"DEPARTMENT_NAME\"<\/span> <span class=\"text-product-orange\">IS NOT NULL<\/span>)<\/span>\n                <\/span>\n                            <span class=\"codeBlock codeBlock__lineContainer\">\n                    <span class=\"codeBlock codeBlock__lineCount\">89<\/span>\n                    <span class=\"codeBlock codeBlock__line\">    );<\/span>\n                <\/span>\n                    <\/code>\n    <\/pre>\n    <\/div>\n<\/section>\n<\/div>\n\n\n\n<div class=\"wp-block-group alignfull has-background is-layout-constrained wp-block-group-is-layout-constrained\" style=\"background-color:#f9f9e1\" data-block-type=\"core\">\n<div class=\"wp-block-stackable-columns alignfull stk-block-columns stk-block stk-66c8395881a8f\" data-block-id=\"66c8395881a8f\"><style>.stk-66c8395881a8f{margin-top:0px !important;margin-bottom:0px !important}.stk-66c8395881a8f-column{max-width:672px !important;justify-content:left !important}<\/style><div class=\"stk-row stk-inner-blocks has-text-align-left stk-block-content stk-content-align stk-66c8395881a8f-column stk--flex alignfull\">\n<div class=\"wp-block-stackable-column stk-block-column stk-column stk-block stk-66c8395881a90\" data-v=\"4\" data-block-id=\"66c8395881a90\"><div class=\"stk-column-wrapper stk-block-column__content stk-container stk-66c8395881a90-container stk--no-background stk--no-padding\"><div class=\"stk-block-content stk-inner-blocks stk-66c8395881a90-inner-blocks\">\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c8394cbc997\" data-block-id=\"stk66c8394cbc997\"><p class=\"stk-block-text__text\">Much more readable, don't you find?<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c8394cbc99c\" data-block-id=\"stk66c8394cbc99c\"><p class=\"stk-block-text__text\"><strong>Note<\/strong>: Keep in mind that the \u201cFormat SQL\u201d options are only available in DbVisualizer Pro. For more information, <a href=\"https:\/\/www.dbvis.com\/pricing\/\">check our pricing page<\/a>.<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c8394cbc9dd\" data-block-id=\"stk66c8394cbc9dd\"><p class=\"stk-block-text__text\">What if you want to format only a portion of the previous SQL statement? You can do that by <em>selecting the SQL code to format and then clicking the \u201cFormat SQL &gt; Format Buffer\u201d option<\/em>:<\/p><\/div>\n<\/div><\/div><\/div>\n<\/div><\/div>\n<\/div>\n\n\n\n<div id=\"img-wrapper-66c8395881a92\" class=\"wp-block-group has-dbvis-light-yellow-background-color has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"padding-top:20px\" data-block-type=\"core\"><section class=\"thetableImage thetableImage__wrapper\">\n    <div class=\"thetableImage thetableImage__container thetableImage__container--dark thetableImage__container--wide thetableImage__container--shadow\">\n        <div class=\"thetableImage thetableImage__imageWrapper thetableImage__imageWrapper--dark thetableImage__imageWrapper--wide thetableImage__imageWrapper--shadow\">\n            <div class=\"thetableImage thetableImage__imageContainer thetableImage__imageContainer--dark thetableImage__imageContainer--wide thetableImage__imageContainer--shadow\">\n                <img decoding=\"async\" width=\"1024\" height=\"547\" src=\"https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716300542549_UntitledProject-1024x547.gif\" class=\"attachment-large size-large\" alt=\"Formatting a portion of the query\" srcset=\"https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716300542549_UntitledProject-1024x547.gif 1024w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716300542549_UntitledProject-300x160.gif 300w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716300542549_UntitledProject-768x410.gif 768w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716300542549_UntitledProject-1300x694.gif 1300w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/s_38272CB1B7AD2DC5CD76B393F385BC0D3C74BD70F120462EC681A960B8552D30_1716300542549_UntitledProject-42x22.gif 42w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/>            <\/div>\n        <\/div>\n                    <span class=\"thetableImage thetableImage__imageCaption thetableImage__imageCaption--dark thetableImage__imageCaption--wide\">Formatting a portion of the query<\/span>\n            <\/div>\n<\/section>\n<\/div>\n\n\n\n<div class=\"wp-block-group alignfull has-background is-layout-constrained wp-block-group-is-layout-constrained\" style=\"background-color:#f9f9e1\" data-block-type=\"core\">\n<div class=\"wp-block-stackable-columns alignfull stk-block-columns stk-block stk-66c8395881a93\" data-block-id=\"66c8395881a93\"><style>.stk-66c8395881a93{margin-top:0px !important;margin-bottom:0px !important}.stk-66c8395881a93-column{max-width:672px !important;justify-content:left !important}<\/style><div class=\"stk-row stk-inner-blocks has-text-align-left stk-block-content stk-content-align stk-66c8395881a93-column stk--flex alignfull\">\n<div class=\"wp-block-stackable-column stk-block-column stk-column stk-block stk-66c8395881a94\" data-v=\"4\" data-block-id=\"66c8395881a94\"><div class=\"stk-column-wrapper stk-block-column__content stk-container stk-66c8395881a94-container stk--no-background stk--no-padding\"><div class=\"stk-block-content stk-inner-blocks stk-66c8395881a94-inner-blocks\">\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c8395881354\" data-block-id=\"stk66c8395881354\"><p class=\"stk-block-text__text\">Wonderful! For more details on this feature, <a href=\"https:\/\/www.dbvis.com\/docs\/ug\/working-with-sql\/formatting-sql\/\">explore our documentation<\/a>.<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-stk66c83958813f8\" id=\"stk66c83958813f8\" data-block-id=\"stk66c83958813f8\"><h2 class=\"stk-block-heading__text\">Conclusion<\/h2><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c83958813fc\" data-block-id=\"stk66c83958813fc\"><p class=\"stk-block-text__text\">In this article, you learned what it means to format SQL query strings and how to do it. This is a useful technique for standardizing SQL code in a codebase and making it more readable and maintainable by applying standard stylistic conventions.<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c8395881401\" data-block-id=\"stk66c8395881401\"><p class=\"stk-block-text__text\">Here, you learned that the ideal solution to SQL query formatting is doing it in your database client. For that, you need a full-featured database client, such as DbVisualizer. This also offers many other capabilities, including query optimization, ERD-like schema generation, and more. <a href=\"https:\/\/www.dbvis.com\/download\/\">Try it for free today!<\/a><\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-stk66c839588140a\" id=\"stk66c839588140a\" data-block-id=\"stk66c839588140a\"><h2 class=\"stk-block-heading__text\">FAQ<\/h2><\/div>\n\n\n\n<div class=\"wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-stk66c839588140f\" id=\"stk66c839588140f\" data-block-id=\"stk66c839588140f\"><h3 class=\"stk-block-heading__text\">What are some online format SQL query tools?<\/h3><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c8395881411\" data-block-id=\"stk66c8395881411\"><p class=\"stk-block-text__text\">Some popular online SQL formatter tools are:<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-icon-list stk-block-icon-list stk-block stk-stk66c83958819aa\" data-block-id=\"stk66c83958819aa\"><style>.stk-stk66c83958819aa .stk-block-icon-list-item__content{gap:8px !important;align-items:baseline !important}.stk-stk66c83958819aa{--stk-icon-list-row-gap:8px !important;--stk-icon-height:8px !important}<\/style><svg style=\"display:none\"><defs><g id=\"stk-icon-list__icon-svg-def-stk66c83958819aa\"><svg xmlns='http:\/\/www.w3.org\/2000\/svg' viewBox='0 0 100 100'><circle cx='50' cy='50' r='40'><\/circle><\/svg><\/g><\/defs><\/svg><div class=\"stk-block-icon-list__ul stk-block-icon-list--column\"><ul class=\"stk-block-icon-list__group\">\n<li class=\"wp-block-stackable-icon-list-item stk-block-icon-list-item stk-block stk-61b0e9b\" data-block-id=\"61b0e9b\"><div class=\"stk-block-icon-list-item__content\"><span class=\"stk--svg-wrapper\"><div class=\"stk--inner-svg\"><svg aria-hidden=\"true\" width=\"32\" height=\"32\"><use xlink:href=\"#stk-icon-list__icon-svg-def-stk66c83958819aa\"><\/use><\/svg><\/div><\/span><span class=\"stk-block-icon-list-item__text\"><a href=\"https:\/\/www.dpriver.com\/pp\/sqlformat.htm\" target=\"_blank\" rel=\"noopener\">www.dpriver.com\/pp\/sqlformat.htm<\/a><\/span><\/div><\/li>\n\n\n\n<li class=\"wp-block-stackable-icon-list-item stk-block-icon-list-item stk-block stk-9844c7f\" data-block-id=\"9844c7f\"><div class=\"stk-block-icon-list-item__content\"><span class=\"stk--svg-wrapper\"><div class=\"stk--inner-svg\"><svg aria-hidden=\"true\" width=\"32\" height=\"32\"><use xlink:href=\"#stk-icon-list__icon-svg-def-stk66c83958819aa\"><\/use><\/svg><\/div><\/span><span class=\"stk-block-icon-list-item__text\"><a href=\"https:\/\/www.red-gate.com\/website\/sql-formatter\" target=\"_blank\" rel=\"noopener\">www.red-gate.com\/website\/sql-formatter<\/a><\/span><\/div><\/li>\n\n\n\n<li class=\"wp-block-stackable-icon-list-item stk-block-icon-list-item stk-block stk-3dd6ffe\" data-block-id=\"3dd6ffe\"><div class=\"stk-block-icon-list-item__content\"><span class=\"stk--svg-wrapper\"><div class=\"stk--inner-svg\"><svg aria-hidden=\"true\" width=\"32\" height=\"32\"><use xlink:href=\"#stk-icon-list__icon-svg-def-stk66c83958819aa\"><\/use><\/svg><\/div><\/span><span class=\"stk-block-icon-list-item__text\"><a href=\"https:\/\/codebeautify.org\/sqlformatter\" target=\"_blank\" rel=\"noopener\">codebeautify.org\/sqlformatter<\/a><\/span><\/div><\/li>\n\n\n\n<li class=\"wp-block-stackable-icon-list-item stk-block-icon-list-item stk-block stk-9806206\" data-block-id=\"9806206\"><div class=\"stk-block-icon-list-item__content\"><span class=\"stk--svg-wrapper\"><div class=\"stk--inner-svg\"><svg aria-hidden=\"true\" width=\"32\" height=\"32\"><use xlink:href=\"#stk-icon-list__icon-svg-def-stk66c83958819aa\"><\/use><\/svg><\/div><\/span><span class=\"stk-block-icon-list-item__text\"><a href=\"https:\/\/sqlformat.org\/\" target=\"_blank\" rel=\"noopener\">sqlformat.org<\/a><\/span><\/div><\/li>\n\n\n\n<li class=\"wp-block-stackable-icon-list-item stk-block-icon-list-item stk-block stk-4139226\" data-block-id=\"4139226\"><div class=\"stk-block-icon-list-item__content\"><span class=\"stk--svg-wrapper\"><div class=\"stk--inner-svg\"><svg aria-hidden=\"true\" width=\"32\" height=\"32\"><use xlink:href=\"#stk-icon-list__icon-svg-def-stk66c83958819aa\"><\/use><\/svg><\/div><\/span><span class=\"stk-block-icon-list-item__text\"><a href=\"https:\/\/poorsql.com\/\" target=\"_blank\" rel=\"noopener\">poorsql.com<\/a><\/span><\/div><\/li>\n<\/ul><\/div><\/div>\n\n\n\n<div class=\"wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-stk66c83958819f5\" id=\"stk66c83958819f5\" data-block-id=\"stk66c83958819f5\"><h3 class=\"stk-block-heading__text\">What are some SQL query date format approaches?<\/h3><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c83958819f9\" data-block-id=\"stk66c83958819f9\"><p class=\"stk-block-text__text\">Some SQL query date format approaches include:<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-icon-list stk-block-icon-list stk-block stk-66c83958819fd\" data-block-id=\"66c83958819fd\"><style>.stk-66c83958819fd .stk-block-icon-list-item__content{gap:4px !important;align-items:baseline !important}.stk-66c83958819fd{--stk-icon-height:16px !important}<\/style><div class=\"stk-block-icon-list__ol stk-block-icon-list--column\"><ol class=\"stk-block-icon-list__group\">\n<li class=\"wp-block-stackable-icon-list-item stk-block-icon-list-item stk-block stk-ae19119\" data-block-id=\"ae19119\"><div class=\"stk-block-icon-list-item__content\"><span class=\"stk-block-icon-list-item__marker\" aria-hidden=\"true\"><\/span><span class=\"stk-block-icon-list-item__text\"><strong>Using <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/date-and-time-functions.html#function_date-format\" target=\"_blank\" rel=\"noopener\"><code>DATE_FORMAT()<\/code><\/a><\/strong>: MySQL function to format dates (e.g., <code>DATE_FORMAT(date, '%Y-%m-%d')<\/code>).<\/span><\/div><\/li>\n\n\n\n<li class=\"wp-block-stackable-icon-list-item stk-block-icon-list-item stk-block stk-fed7304\" data-block-id=\"fed7304\"><div class=\"stk-block-icon-list-item__content\"><span class=\"stk-block-icon-list-item__marker\" aria-hidden=\"true\"><\/span><span class=\"stk-block-icon-list-item__text\"><strong>Using <a href=\"https:\/\/docs.oracle.com\/en\/database\/oracle\/oracle-database\/19\/sqlrf\/TO_CHAR-datetime.html\" target=\"_blank\" rel=\"noopener\"><code>TO_CHAR()<\/code><\/a><\/strong>: Oracle function to format dates (e.g., <code>TO_CHAR(date, 'YYYY-MM-DD')<\/code>). This function is also available in PostgreSQL.<\/span><\/div><\/li>\n\n\n\n<li class=\"wp-block-stackable-icon-list-item stk-block-icon-list-item stk-block stk-962f118\" data-block-id=\"962f118\"><div class=\"stk-block-icon-list-item__content\"><span class=\"stk-block-icon-list-item__marker\" aria-hidden=\"true\"><\/span><span class=\"stk-block-icon-list-item__text\"><strong>Using <a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/t-sql\/functions\/format-transact-sql?view=sql-server-ver16\" target=\"_blank\" rel=\"noopener\"><code>FORMAT()<\/code><\/a><\/strong>: SQL Server function to format dates (e.g., <code>FORMAT(date, 'yyyy-MM-dd')<\/code>).<\/span><\/div><\/li>\n<\/ol><\/div><\/div>\n\n\n\n<div class=\"wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-stk66c8395881a24\" id=\"stk66c8395881a24\" data-block-id=\"stk66c8395881a24\"><h3 class=\"stk-block-heading__text\">What impact does the format of an SQL query have on readability?<\/h3><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c8395881a26\" data-block-id=\"stk66c8395881a26\"><p class=\"stk-block-text__text\">The format of a SQL query string significantly impacts its readability. Proper formatting and spacing help to effectively grasp the structure of the query, making it easier for the reader to understand what the query does.<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-stk66c8395881a2d\" id=\"stk66c8395881a2d\" data-block-id=\"stk66c8395881a2d\"><h3 class=\"stk-block-heading__text\">Is it possible to format SQL code directly in a database client?<\/h3><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c8395881a2f\" data-block-id=\"stk66c8395881a2f\"><p class=\"stk-block-text__text\">Yes, but you need the right tool. A full-featured database client like DbVisualizer comes with SQL query formatting capabilities and <a href=\"https:\/\/www.dbvis.com\/features\/feature-list\/\">many other features<\/a>.<\/p><\/div>\n\n\n\n<div class=\"wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-stk66c8395881a3b\" id=\"stk66c8395881a3b\" data-block-id=\"stk66c8395881a3b\"><h3 class=\"stk-block-heading__text\">What role does indentation play in SQL query formatting?<\/h3><\/div>\n\n\n\n<div class=\"wp-block-stackable-text stk-block-text stk-block stk-stk66c8395881a3d\" data-block-id=\"stk66c8395881a3d\"><p class=\"stk-block-text__text\">Indentation plays a crucial role in SQL query formatting by improving readability and highlighting the query's structure and logic. It visually separates different parts of the query, such as clauses and <a href=\"https:\/\/www.dbvis.com\/thetable\/the-complete-guide-to-sql-subqueries\/\">SQL subqueries<\/a>. This enables developers to quickly identify the relationships and hierarchy within the tables and columns used in the query.<\/p><\/div>\n<\/div><\/div><\/div>\n<\/div><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\" data-block-type=\"core\" data-block-type=\"core\" data-block-type=\"core\">\n<div class=\"wp-block-stackable-columns alignfull stk-block-columns stk-block stk-1d92408 stk-block-background\" data-block-id=\"1d92408\"><style>.stk-1d92408 {background-color:var(--stk-global-color-70050, #f9f9e1) !important;margin-bottom:0px !important;}.stk-1d92408:before{background-color:var(--stk-global-color-70050, #f9f9e1) !important;}<\/style><div class=\"stk-row stk-inner-blocks stk-block-content stk-content-align stk-1d92408-column alignwide\">\n<div class=\"wp-block-stackable-column stk-block-column stk-column stk-block stk-b8a8e51\" data-v=\"4\" data-block-id=\"b8a8e51\"><div class=\"stk-column-wrapper stk-block-column__content stk-container stk-b8a8e51-container stk--no-background stk--no-padding\"><div class=\"stk-block-content stk-inner-blocks stk-b8a8e51-inner-blocks\">\n<div class=\"wp-block-stackable-image stk-block-image stk-block stk-d9669e0\" data-block-id=\"d9669e0\"><figure><a class=\"stk-link\" href=\"\/download\/\" target=\"_blank\" rel=\"noreferrer noopener\"><span class=\"stk-img-wrapper stk-image--shape-stretch\"><img decoding=\"async\" class=\"stk-img wp-image-26081\" src=\"https:\/\/www.dbvis.com\/wp-content\/uploads\/2022\/12\/Banner-1-scaled.png\" width=\"2560\" height=\"577\" alt=\"Dbvis download link img\" srcset=\"https:\/\/www.dbvis.com\/wp-content\/uploads\/2022\/12\/Banner-1-scaled.png 2560w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2022\/12\/Banner-1-300x68.png 300w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2022\/12\/Banner-1-1024x231.png 1024w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2022\/12\/Banner-1-768x173.png 768w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2022\/12\/Banner-1-1536x346.png 1536w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2022\/12\/Banner-1-2048x462.png 2048w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2022\/12\/Banner-1-1300x293.png 1300w, https:\/\/www.dbvis.com\/wp-content\/uploads\/2022\/12\/Banner-1-42x9.png 42w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><\/span><\/a><\/figure><\/div>\n<\/div><\/div><\/div>\n<\/div><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>intro Let's look at how to format SQL query strings and find out why doing it in your database client makes everything easier and faster. SQL queries can become long and messy, making it harder for developers to understand what is going on. If you have come across a poorly formatted query at least once, [&hellip;]<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[17],"class_list":["post-20358","post","type-post","status-publish","format-standard","hentry","category-thetable","tag-sql"],"acf":{"updated_date":null,"featured":false,"prio":"","highlighted":false,"type":"Guide","length":"7 min","author":[8009],"tools_used":[12272]},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How To Format SQL Query Strings<\/title>\n<meta name=\"description\" content=\"Let&#039;s look at how to format SQL query strings and find out why doing it in your database client makes everything easier and faster.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbvis.com\/thetable\/how-to-format-sql-query-strings\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Format SQL Query Strings\" \/>\n<meta property=\"og:description\" content=\"Let&#039;s look at how to format SQL query strings and find out why doing it in your database client makes everything easier and faster.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbvis.com\/thetable\/how-to-format-sql-query-strings\/\" \/>\n<meta property=\"og:site_name\" content=\"DbVisualizer\" \/>\n<meta property=\"article:author\" content=\"Antonello Zanini\" \/>\n<meta property=\"article:published_time\" content=\"2024-10-16T08:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/og-198.png\" \/>\n<meta name=\"author\" content=\"Antonello Zanini\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How To Format SQL Query Strings\" \/>\n<meta name=\"twitter:description\" content=\"Let&#039;s look at how to format SQL query strings and find out why doing it in your database client makes everything easier and faster.\" \/>\n<meta name=\"twitter:creator\" content=\"@dbvisualizer\" \/>\n<meta name=\"twitter:site\" content=\"@dbvisualizer\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Antonello Zanini\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 min\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How To Format SQL Query Strings","description":"Let's look at how to format SQL query strings and find out why doing it in your database client makes everything easier and faster.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbvis.com\/thetable\/how-to-format-sql-query-strings\/","og_locale":"en_US","og_type":"article","og_title":"How To Format SQL Query Strings","og_description":"Let's look at how to format SQL query strings and find out why doing it in your database client makes everything easier and faster.","og_url":"https:\/\/www.dbvis.com\/thetable\/how-to-format-sql-query-strings\/","og_site_name":"DbVisualizer","article_author":"Antonello Zanini","article_published_time":"2024-10-16T08:00:00+00:00","og_image":[{"url":"https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/09\/og-198.png","type":"","width":"","height":""}],"author":"Antonello Zanini","twitter_card":"summary_large_image","twitter_title":"How To Format SQL Query Strings","twitter_description":"Let's look at how to format SQL query strings and find out why doing it in your database client makes everything easier and faster.","twitter_creator":"@dbvisualizer","twitter_site":"@dbvisualizer","twitter_misc":{"Written by":"Antonello Zanini","Est. reading time":"7 min"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/www.dbvis.com\/thetable\/how-to-format-sql-query-strings\/#article","isPartOf":{"@id":"https:\/\/www.dbvis.com\/thetable\/how-to-format-sql-query-strings\/"},"author":{"name":"Linda","@id":"https:\/\/www.dbvis.com\/#\/schema\/person\/220b74381f69bb6f0b2de51c19c6c5c3"},"headline":"How To Format SQL Query Strings","datePublished":"2024-10-16T08:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbvis.com\/thetable\/how-to-format-sql-query-strings\/"},"wordCount":964,"publisher":{"@id":"https:\/\/www.dbvis.com\/#organization"},"keywords":["SQL"],"articleSection":["TheTable"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.dbvis.com\/thetable\/how-to-format-sql-query-strings\/","url":"https:\/\/www.dbvis.com\/thetable\/how-to-format-sql-query-strings\/","name":"How To Format SQL Query Strings","isPartOf":{"@id":"https:\/\/www.dbvis.com\/#website"},"datePublished":"2024-10-16T08:00:00+00:00","description":"Let's look at how to format SQL query strings and find out why doing it in your database client makes everything easier and faster.","breadcrumb":{"@id":"https:\/\/www.dbvis.com\/thetable\/how-to-format-sql-query-strings\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbvis.com\/thetable\/how-to-format-sql-query-strings\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbvis.com\/thetable\/how-to-format-sql-query-strings\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Hem","item":"https:\/\/www.dbvis.com\/"},{"@type":"ListItem","position":2,"name":"How To Format SQL Query Strings"}]},{"@type":"WebSite","@id":"https:\/\/www.dbvis.com\/#website","url":"https:\/\/www.dbvis.com\/","name":"DbVisualizer","description":"","publisher":{"@id":"https:\/\/www.dbvis.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbvis.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.dbvis.com\/#organization","name":"DbVisualizer","alternateName":"DbVis","url":"https:\/\/www.dbvis.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbvis.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/08\/dbvisualizer_logo_squircle.svg","contentUrl":"https:\/\/www.dbvis.com\/wp-content\/uploads\/2023\/08\/dbvisualizer_logo_squircle.svg","width":72,"height":72,"caption":"DbVisualizer"},"image":{"@id":"https:\/\/www.dbvis.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/dbvisualizer"]},{"@type":"Person","@id":"https:\/\/www.dbvis.com\/#\/schema\/person\/220b74381f69bb6f0b2de51c19c6c5c3","name":"Linda","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbvis.com\/wp-content\/litespeed\/avatar\/7e4cf781845f1f27037a5c6b10a6a5d7.jpg?ver=1776302580","url":"https:\/\/www.dbvis.com\/wp-content\/litespeed\/avatar\/7e4cf781845f1f27037a5c6b10a6a5d7.jpg?ver=1776302580","contentUrl":"https:\/\/www.dbvis.com\/wp-content\/litespeed\/avatar\/7e4cf781845f1f27037a5c6b10a6a5d7.jpg?ver=1776302580","caption":"Linda"}}]}},"_links":{"self":[{"href":"https:\/\/www.dbvis.com\/wp-json\/wp\/v2\/posts\/20358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbvis.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbvis.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbvis.com\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbvis.com\/wp-json\/wp\/v2\/comments?post=20358"}],"version-history":[{"count":1,"href":"https:\/\/www.dbvis.com\/wp-json\/wp\/v2\/posts\/20358\/revisions"}],"predecessor-version":[{"id":20539,"href":"https:\/\/www.dbvis.com\/wp-json\/wp\/v2\/posts\/20358\/revisions\/20539"}],"acf:post":[{"embeddable":true,"href":"https:\/\/www.dbvis.com\/wp-json\/wp\/v2\/thetable-tool\/12272"},{"embeddable":true,"href":"https:\/\/www.dbvis.com\/wp-json\/wp\/v2\/thetable-author\/8009"}],"wp:attachment":[{"href":"https:\/\/www.dbvis.com\/wp-json\/wp\/v2\/media?parent=20358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbvis.com\/wp-json\/wp\/v2\/categories?post=20358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbvis.com\/wp-json\/wp\/v2\/tags?post=20358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}