> For the complete documentation index, see [llms.txt](https://learnsql.gitbook.io/lernmysql/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learnsql.gitbook.io/lernmysql/welcome-to-the-mysql-tutorial/sql-create-view-statement.md).

# SQL CREATE VIEW Statement

In SQL, a view is a virtual table based on the result-set of an SQL statement.

#### CREATE VIEW Syntax

```
CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
```

SQL sau đây tạo ra một khung nhìn hiển thị tất cả các khách hàng từ USA:

```
CREATE VIEW USA AS SELECT customerNumber,customerName, country 
FROM customers 
WHERE country = 'USA';
```

#### SQL CREATE OR REPLACE VIEW Syntax

```
CREATE OR REPLACE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
```

SQL sau đây thêm cột "phone" vào chế độ xem "USA":

```
CREATE OR REPLACE  VIEW USA AS SELECT customerNumber,customerName, country, phone 
FROM customers WHERE country = 'USA';
```

### SQL Dropping a View

```
DROP VIEW view_name;
```

```
DROP view USA;
```
