Lecture32 Declarative Languages
一、Declarative Languages
- 定义
①declarative languages such asSQL & Prolog
② imperative languages such asPython & Scheme
二、SQL(Structured Query Language )
- 基本语句
1⃣️ select statement creates a new table
2⃣️ create table statement gives a global name to a table
3⃣️ other statements : analyze, delete, explain, insert, replace, update, etc.
4⃣️select statement
-
SQL Getting Started
Use sqlite online: http://kripken.github.io/sql.js/GUI/
-
Selecting Value Literals
Select语句的用法:
select [expression] as [name], [expression] as [name]; …
- Naming Tables
Creat语句的用法:
create table [name] as [select statement];
举例:
三、Projecting Tables
- Select Statements Project Existing Tables
语句的用法
1⃣️ A select statement can specify an input table using a from clause
2⃣️ A subset of the rows of the input table can be selected using a where clause An ordering over the remaining rows can be
3⃣️ declared using an order by clause Column descriptions determine how each input row is projected to a result row
基本句式:
1⃣️ select [expression] as [name], [expression] as [name], … ;
2⃣️ select [columns] from [table] where [condition] order by [order];
举例
题目:
操作及运行结果1
操作及运行结果2
在终端的操作:
四、Arithmetic
- Arithmetic in Select Expressions
In a select expression, column names evaluate to row values Arithmetic expressions can combine row values and constants
语句及举例:
- 问题及答案
问题
解答:
1.2.
3.