Home >Database >Mysql Tutorial >MySQL DDL operations

MySQL DDL operations

(*-*)浩
(*-*)浩Original
2019-05-07 11:14:333556browse

DDL in MySQL represents the database definition statement, which is used to create tables, indexes, views, stored procedures, triggers, etc. in the database.

Commonly used statement keywords are: CREATE, ALTER, DROP, TRUNCATE, COMMENT, RENAME.

Recommended courses: MySQL Tutorial.

MySQL DDL operations


The schema described by DDL must be compiled by computer software and converted into a format that is convenient for computer storage, query and Manipulated formats, the program that completes this conversion is called a pattern compiler.

The schema compiler processes schema definitions to mainly produce two types of data: Data dictionaries and data type and structure definitions.

The data dictionary and the internal structure information of the database are the basis for creating the database corresponding to the schema. Based on this information, the logical structure corresponding to each database is created; access and query of database data are also based on the schema information. Determine the method and type of data access, as well as the relationship between data and the integrity constraints on the data.

The data dictionary is the internal information representation of the schema. The storage method of the data dictionary varies for different DBMS.

The definition of data types and structures means that when an application program connects to a database, the application program needs to understand the data types and structures generated and extracted. It is the data type and structure definition of the user workspace provided for various host languages, making the logical structure of the user workspace and the database consistent, reducing the data conversion process. The definition of this data type and structure is usually used in a header file. accomplish.

There are usually two ways to define a database schema: interactively defining the schema and defining the schema through data description language DDL description text.

Database level

Show all databases: show databases;

Enter a database: use db_name;

Create a database: create databse db_name;

Create a database with a specified character set: create database db_name character set utf8;

Display database creation information: show create database db_name;

Modify the encoding of the database: alter database db_name character set gb2312;

Delete a database: drop database db_name;

The above is the detailed content of MySQL DDL operations. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn