2016년 8월 22일 월요일

Intro to SQL & Data Types in SQL

Let's learn SQL.

SQL stands for Structured Query Language.
It is used to communicate with a database. Query in SQL lets you organize and find the data you want in large database.

So what can you do with SQL?

  • Execute queries against a DB
  • Retrieve data from a DB
  • Insert/update/delete records in a DB
  • Create new DB
  • Create new table in a DB
  • Create stored procedures in DB
  • Create views in a DB
  • Set permissions on tables, procedures and views


We are first going to learn the main data types used in SQL.

There are a few different data types in SQL.
Data types could be divided into 3 main types :

1. Text and string types
text - a string of any length like Python str or unicode types
char(n) - a string of exactly n characters
archer(n) - a string of up to n characters

- String should always be put in 'single quotes' around text strings and date/time values
ex) '2012-11-23' : date/ text
without quotes 2012-11-23 : this is an integer expression

2. Numeric types
integer - an integer value, like Python int
real - a floating-point value, like Python float. Accurate up to six decimal places.
double precision - a higher-precision floating-point value. Accurate up to 15 decimal places.
decimal - an exact decimal value

3. Date and time types
date - a calendar date; including year, month, and day.
time - a time of day
timestamp - a date and time together



댓글 없음:

댓글 쓰기