SQL基础语法

内容纲要

SQL分类

  • DDL:数据定义语言。CREATE \ ALTER \ DROP \ RENAME \ TRUNCATE
  • DML:数据操作语言。INSERT \ DELETE \ UPDATE \ SELECT
  • DCL:数据控制语言。COMMIT \ ROLLBACK \ SAVEPOINT \ GRANT \ REVOKE

基本的SELECT语句

  1. SELECT ...
  2. SELECT ... FROM ...(字符串用')

列的别名

alias = AS

SELECT employee_id emp_id, last_name AS lname, department_id "xxx", salary * 12 As "annual sal" FROM employees;

去除重复行

SELECT DISTINCT department_id FROM employees;

着重号`

查询常数

SELECT 'xxx', 123, employee_id, last_name FROM employees;

显示表结构

DESC employees;

过滤数据

SELECT ... FROM ... WHERE ...

留下评论

您的电子邮箱地址不会被公开。