1. What is DDL?
In the context of SQL, Data Definition Language(DDL) is a syntax for creating and modifying database objects such as tables, indices, and users. DDL statement are similar to a computer programming language for defining dat structures, especially database schemas.
Common examples of DDL statements include CREATE, ALTER, and DROP.
2. CREATE
CREATE clause make tables in database.
CREATE TABLE [table_name] (
[column_name1] [column_type1] PRIMARY KEY,
[column_name2] [column_type2],
FOREIGN KEY ([column_name2]) REFERENCE parent_table([column_name2])
...
);
There are some type we can define such as TEXT, INTEGER, REAL, NUMBER, BLOB. In the table, there are a primary key and a foreign key separately from the data type. The default key is a column with a unique value inside the table and becomes a criterion for identifying the table. The wagon key efers to a column that can be connected to another table, and the basic key of the other table operates as the wagon key of the corresponding table.
3. ALTER
The ALTER clause modifies an existing database object. An ALTER clause in SQL changes the properties of an object inside of RDBMS. The types of objects that can be altered depends on which RDBMS is being used.
ALTER TABLE [table_name]
ADD COLUMN [column_name1] [column_type1];
ALTER TABLE [table_name]
DROP COLUMN [column_name];
4. DELETE
DELETE clause drop tables in database.
DELETE TABLE [table_name];
Source from : https://en.wikipedia.org/wiki/Data_definition_language
'DB > SQLite' 카테고리의 다른 글
[sqlite3] Using SQLite in IDEs (0) | 2022.09.28 |
---|---|
[sqlite3] Creating a sqlite database from CSV file (0) | 2022.09.24 |
[Syntax] Writing Efficient Query (0) | 2022.09.24 |
[Syntax] Merging Tables (0) | 2022.09.23 |
[Syntax] Data Manipulation Language (0) | 2022.09.23 |