国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

PHP development basic tutorial structure definition statement

Introduction

DDL is a data definition language. Simply put, it is a language for creating, deleting, modifying and operating databases, data tables, and data fields. , the biggest difference between it and data operation statements (DML) is that DML (data operation statements) operate on the internal data of the table, and do not involve the definition of the table, modification of the structure, or other objects.

In this chapter, we divided it into three parts when explaining this section:

  • Database operation

  • Data table operation

  • Data field operations


##Database operations

1.Create database

##CategoryBasic syntaxExampleExample description

Example:

80.png

Click to execute, and there will be an additional php database on the right

81.png

2View database

Detailed explanation
create database database name;
create database php ;
Create a database, the name of the database is php
## CategoryDetailed explanationBasic syntaxshow databases;Example descriptionShow all databases of the current server

##Note: show refers to display database refers to the database
databases is the plural form of database, referring to all databases.

Enter show databases; the display is as follows

82.png

##3. Select the database

Basic syntax:

#CategoryDetailed explanationuse library name;use php;Using database php
Basic syntax
Example
Example description

Note:
Use refers to use;
library name is the name of the specific database in the current database system;

83.png# Note: We can use the USE statement to switch the database to be operated at any time

## 4. View tables in the database

# After entering the library, we can see how many data tables in this library.


CategoryDetailed explanationBasic syntax show tables; # Example Example
  • <option id="88iow"></option>
    <noframes id="88iow"><source id="88iow"></source></noframes>





      • ## Show all the tables under the current database
        ##


        After using use to enter a database, you can use show tables

        Example to view the tables of the current database:

        84.png

        Note: The database must be selected before you can view the table

        5. Delete database

        ## drop database liwenkai; Example description Delete a database, the name of the database is liwenkai

        Note:
        Drop is Chinese that can be translated as a finger.
        ## Note: After the database is deleted, all the following data will be deleted, so you must carefully and make a corresponding backup before deleting.


        ##Q

        #1. Create table

        ##Category

        ##Category
        Detailed explanation
        Basic syntax
        drop database library name;
        Example


        Detailed explanation
          <fieldset id="88iow"><acronym id="88iow"></acronym></fieldset>

          ##Basic syntax

          create table table name (field name 1 field type,.... field name n field type n);

          Example

          create table user(username varchar(20),password varchar(32));
          ##Example description
          Create a table named user, the first field is username, the field type of the table is varchar, the length is 32 length. The second field is password, the type is also varchar, and the length is also 32 characters.

          Note:

          • In order to better let everyone get started, data types are temporarily outside the scope of our explanation in this chapter. I’m afraid that everyone will focus on one thing and lose another. It is very important to quickly learn the management and operation statements of the database. Data types, fields, character sets, and engines are all knowledge points to understand.

          • . As for field types, you only need to learn int now, which represents integer type. float represents floating point. char and varchar can represent strings.

          • We can add the length after the type, such as: varchar(20).

          View table field structure information

          2. Delete table

          Category
          Detailed explanation
          Basic syntax
          desc table name;
          ##Example
          desc emp
          Example description
          View the table structure of the emp table
          ##Basic syntax Drop table Name; # Example Example description



          Note: Delete the table. Both tables and data will be lost. Do not delete the data before the important table.

          3. Specify table engine and character set

          ## At the end of the creation table, we often use MyISAM or InnoDB engine. When designated by the engine, we can use:

          ENGINE = InnoDB

          Speculating Form default character set:

          DEFAULT CHARSET = UTF8

          ## The effect is as follows:

          Create Table Emp (

          Useraaname Varchar (10) Default Null,

          Password Date Default Null,

          )

          ## database field operation


          #qian directly uses PHPMYADMIN to create the field in the table # Click the structure:

          Fill in the information in each field85.png

          ##Click Execute to complete86.png

          Deleting or modifying fields is also done in phpAdmin. You can try it yourself

          Continuing Learning

          ||
          <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php.cn</title> </head> <body> <?php echo "Hello World!!!"; ?> </body> </html>
          submitReset Code
        • ##category
          Detailed explanation



          emp;


          Delete table emp

        • <source id="88iow"><dd id="88iow"></dd></source>