SQL进阶---第一单元(第一到第三课)、Manipulation
2017-10-08 18:36
513 查看
SQL进阶---第一单元、Manipulation
第一课、Introduction
MANIPULATIONIntroduction
Let's begin by entering a SQLcommand. In the code editor type
SELECT *FROM celebs;
You will run all of your SQLcommands in this course by pressing the Run button at the bottom of the codeeditor.
Instruction
select * from celebs;
QueryResults
DatabaseSchema
第二课、RelationalDatabases
MANIPULATION Statements
Nice work. In one line of code, you returned information from arelational database. We'll take a look at what this code means soon, for nowlet's focus on what relational databases are and how
they are organized.
1. A relational database is a database thatorganizesinformation into one or more tables. Here the relational
database contains onetable.
2. A table is a collection of data organized intorows and columns. Tables are sometimes referred to as relations. Here the table is
3. A column is a set of data values of aparticular type. Here
and
4. A row is a single record in a table.The first row in the celebstable has:
· An id of 1
· A name of Justin Bieber
All data stored in a relational database is of a certain data type. Someof the most common data types are:
1. Integer, a positive or negat
c21d
ive whole number
2. Text, a text string
3. Date, the date formatted as YYYY-MM-DD for the year, month, andday
4. Real, a decimal value
第三课、CREATE TABLE
[b]MANIPULATION Statements[/b]
The above code is a SQL statement. A statement is text that thedatabase recognizes as avalid command. Statements always end in a semi-colon
Let's break down the components of a statement:
1.
Clauses perform specific tasks in SQL. By convention, clausesare written in
capitalletters. Clauses can also be referred to ascommands.
2.
is applied to.
3.
a parameter. A parameter is a list of columns, data types, or values thatare passed to a clause as an argument. Here, the parameter isa
list of column names andthe associated data type.
The structure of SQL statements vary. The number of lines useddo not matter. A statement can be written all on one line, or split up acrossmultiple lines if it makes it easier to read. In this course, you will becomefamiliar with
the structure of common statements.
Instructions
1.Now that you have a goodunderstanding of SQL syntax, let's create a new table.In the code editor type:
CREATETABLE celebs (
idINTEGER,
nameTEXT,
ageINTEGER
);
We will learn how to view this table in the next exercise after we haveadded some data to it.
CREATE TABLE celebs
(
idINTEGER,
name TEXT,
age INTEGER
);
Run a query to see results.
第一课、Introduction
MANIPULATIONIntroduction
Let's begin by entering a SQLcommand. In the code editor type
SELECT *FROM celebs;
You will run all of your SQLcommands in this course by pressing the Run button at the bottom of the codeeditor.
Instruction
select * from celebs;
QueryResults
id | name | age |
1 | Justin Bieber | 22 |
2 | Beyonce Knowles | 33 |
3 | Jeremy Lin | 26 |
4 | Taylor Swift | 26 |
Celebs 4 rows | |
id | INTEGER |
name | TEXT |
age | INTEGER |
第二课、RelationalDatabases
MANIPULATION Statements
SELECT * FROM celebs;
Nice work. In one line of code, you returned information from arelational database. We'll take a look at what this code means soon, for nowlet's focus on what relational databases are and how
they are organized.
1. A relational database is a database thatorganizesinformation into one or more tables. Here the relational
database contains onetable.
2. A table is a collection of data organized intorows and columns. Tables are sometimes referred to as relations. Here the table is
celebs.
3. A column is a set of data values of aparticular type. Here
id,
name,
and
ageare each columns.
4. A row is a single record in a table.The first row in the celebstable has:
· An id of 1
· A name of Justin Bieber
All data stored in a relational database is of a certain data type. Someof the most common data types are:
1. Integer, a positive or negat
c21d
ive whole number
2. Text, a text string
3. Date, the date formatted as YYYY-MM-DD for the year, month, andday
4. Real, a decimal value
第三课、CREATE TABLE
[b]MANIPULATION Statements[/b]
CREATETABLE table_name (
column_1 data_type,
column_2 data_type,
column_3 data_type
);
The above code is a SQL statement. A statement is text that thedatabase recognizes as avalid command. Statements always end in a semi-colon
;.
Let's break down the components of a statement:
1.
CREATE TABLEis a clause.
Clauses perform specific tasks in SQL. By convention, clausesare written in
capitalletters. Clauses can also be referred to ascommands.
2.
table_namerefers to the name of the table that thecommand
is applied to.
3.
(column_1 data_type, column_2 data_type, column_3data_type)is
a parameter. A parameter is a list of columns, data types, or values thatare passed to a clause as an argument. Here, the parameter isa
list of column names andthe associated data type.
The structure of SQL statements vary. The number of lines useddo not matter. A statement can be written all on one line, or split up acrossmultiple lines if it makes it easier to read. In this course, you will becomefamiliar with
the structure of common statements.
Instructions
1.Now that you have a goodunderstanding of SQL syntax, let's create a new table.In the code editor type:
CREATETABLE celebs (
idINTEGER,
nameTEXT,
ageINTEGER
);
We will learn how to view this table in the next exercise after we haveadded some data to it.
CREATE TABLE celebs
(
idINTEGER,
name TEXT,
age INTEGER
);
Run a query to see results.
Database Schema
Celebs 0 rows | |
id | INTEGER |
name | TEXT |
age | INTEGER |
相关文章推荐
- SQL进阶---第一单元(第四到第六课)、Manipulation
- SQL进阶---第一单元(第七到第十课)、Manipulation
- 按第一学期、第二学期、第三学期、……第十学期排序的SQL语句
- SQL进阶---第二单元(第一到第四课)、Queries
- T-SQL查询进阶--流程控制语句
- 三个三位数,第一加第二等于第三,三个数所有各个位的数都不相同(1-9),第二个数是第一个数的两倍,求三个数
- T-SQL查询进阶--详解公用表表达式(CTE)
- oralce实战第七天--pl/sql的进阶、分页存储过程、例外和视图
- SQL学习笔记6:进阶之SQL Constraints(约束)
- PHP进阶(第三弹:正则表达式)
- 5位运动员参加了10米台跳水比赛,有人让他们预测比赛结果 A选手说:B第二,我第三; B选手说:我第二,E第四; C选手说:我第一,D第二; D选手说:C最后,我第三; E选手说:我第四,A
- 【sql进阶】SQL Server 将某一列的值拼接成字符串
- 二十五、oracle pl/sql进阶--控制结构(分支,循环,控制)
- SqlServer——事务一编程进阶(SqlServer技术内幕 T-SQL程序设计 第九章
- 通过sqli-labs学习sql注入——进阶挑战之less23-28a
- 【T-SQL进阶】02.理解SQL查询的底层原理
- 2013年7月份全球数据库排名,Oracle第一,SQL Server第二,MySQL第三
- 关于SQL的几道小题详解(sql进阶)
- T-SQL查询进阶—理解SQL Server中的锁
- SQL进阶提升(试题)-学习sql server2005 step by step(九)