• Home
  • News
  • Companies
  • Policy
  • Contacts
    • AED
    • AFN
    • ALL
    • AMD
    • ANG
    • AOA
    • ARS
    • AUD
    • AWG
    • AZN
    • BAM
    • BBD
    • BDT
    • BGN
    • BHD
    • BIF
    • BMD
    • BND
    • BOB
    • BRL
    • BSD
    • BTC
    • BTN
    • BWP
    • BYN
    • BYR
    • BZD
    • CAD
    • CDF
    • CHF
    • CLF
    • CLP
    • CNH
    • CNY
    • COP
    • CRC
    • CUC
    • CUP
    • CVE
    • CZK
    • DJF
    • DKK
    • DOP
    • DZD
    • EGP
    • ERN
    • ETB
    • EUR
    • FJD
    • FKP
    • GBP
    • GEL
    • GGP
    • GHS
    • GIP
    • GMD
    • GNF
    • GTQ
    • GYD
    • HKD
    • HNL
    • HRK
    • HTG
    • HUF
    • IDR
    • ILS
    • IMP
    • INR
    • IQD
    • IRR
    • ISK
    • JEP
    • JMD
    • JOD
    • JPY
    • KES
    • KGS
    • KHR
    • KMF
    • KPW
    • KRW
    • KWD
    • KYD
    • KZT
    • LAK
    • LBP
    • LKR
    • LRD
    • LSL
    • LTL
    • LVL
    • LYD
    • MAD
    • MDL
    • MGA
    • MKD
    • MMK
    • MNT
    • MOP
    • MRO
    • MRU
    • MUR
    • MVR
    • MWK
    • MXN
    • MYR
    • MZN
    • NAD
    • NGN
    • NIO
    • NOK
    • NPR
    • NZD
    • OMR
    • PAB
    • PEN
    • PGK
    • PHP
    • PKR
    • PLN
    • PYG
    • QAR
    • RON
    • RSD
    • RUB
    • RWF
    • SAR
    • SBD
    • SCR
    • SDG
    • SEK
    • SGD
    • SHP
    • SLE
    • SLL
    • SOS
    • SRD
    • SSP
    • STD
    • STN
    • SVC
    • SYP
    • SZL
    • THB
    • TJS
    • TMT
    • TND
    • TOP
    • TRY
    • TTD
    • TWD
    • TZS
    • UAH
    • UGX
    • USD
    • UYU
    • UZS
    • VEF
    • VES
    • VND
    • VUV
    • WST
    • XAF
    • XAG
    • XAU
    • XCD
    • XCG
    • XDR
    • XOF
    • XPF
    • YER
    • ZAR
    • ZMK
    • ZMW
    • ZWL
  • Login
  • General
  • Home NEW
  • News NEW
  • Companies
  • Trading map
  • TOOLS
    • Whois
    • RBLS Check
    • Port Check
    • Ping Check
    • DIG Check
    • IP Check
    • BGP Check
    • Traceroute
    • Speedtest
    • Whoer
  • TRADING
    • IPv4
    • Dedicated
    • Cloud/VPS
    • Backup
    • VPN
    • Colocation
    • Domain Names
  1. News
  2. 5 life hacks for more efficient SQL work
0
5 life hacks for more efficient SQL work
24 January 2020

5 life hacks for more efficient SQL work

Name columns and tables with simple names

Use one word to name the table instead of two. If you still need to use a few words for the table, use underscores instead of spaces or dots in the title.

If you use dots in the names of objects, you get confused between the names of schemas and databases. If you use spaces, you will need to add quotation marks in the request for it to start.

Capitalize the names of columns and tables so that users don’t need to remember where to write which letter if you go to a case-sensitive database.

Handle dates in SQL correctly

Write dates in datetime format so that the databases work faster.

Dates stored in strings are more difficult to work with. Make sure there are no dates in the strings.

Do not divide the year, month, and day into separate columns. This makes it harder to write and filter queries.

Use UTC for your time zone. If you have a hybrid of non-UTC and UTC zones, understanding the data will be much more difficult.

Understand the execution order

When you understand the order in which queries are executed, you can understand how the query works, or why it does not start.

FROM - includes JOINs, so use a CTE or subquery to filter data first.

WHERE - restricts the attached dataset.

GROUP BY - collapses fields with aggregate functions (COUNT, MAX, SUM, AVG)

HAVING - performs the same function as WHERE with aggregated values.

SELECT - sets the values ​​and aggregations in the data array after grouping.

ORDER BY - Returns a table sorted by one or more columns.

LIMIT - sets how many rows to return so as not to output too much data.

Remember the NULL Limitations

NULL means that the value is unknown - but it is not zero and not empty. Therefore, if you are comparing NULL values ​​with NULL, it is difficult to understand something. Which query you ask in the code affects the strategy you need to choose.

Create a table correctly

When you create a table from a table, use SELECT TOP 0 to create a table structure before inserting data there. To do this, you need to perform two steps instead of one, but in the end the request will be processed faster:

insert into <table name2>

select [ID], [CreatedDate], [RegionName], [SalesPerson]

from <table name1>


#SQL

Views
Shares
0
Comments
0

Comments

Please sign-in to comment here

Latest news
  • Facebook improves connectivity in the African region with an undersea internet cable
    7 November 2021

  • Can blind spots be avoided when monitoring DCs?
    3 November 2021

  • Influence of automation in DC on engineering personnel
    30 October 2021

  • The frequency of accidents in DC has decreased and the sum of damage has increased significantly
    26 October 2021

How to become LIR in 7 days
How to become LIR in 7 days

Buy or Sell IPv4 buy in Europe. Best price

30 August 2018
How to avoid mistakes when choosing a hosting
How to avoid mistakes when choosing a hosting

How to avoid mistakes when choosing a hosting

17 September 2018
Chinese manufacturer Loongson will enter the market ..
Chinese manufacturer Loongson will enter the market ..

Chinese manufacturer Loongson will enter the market with 16-core processor in 2020

11 October 2018
4 virtualization trends in 2019
4 virtualization trends in 2019

4 virtualization trends in 2019

2 February 2019

...

Do you like cookies? 🍪 We use cookies to ensure you get the best experience on our website. By using our website you agree with our policy!