当前位置:网站首页>MySQL basic learning notes 03

MySQL basic learning notes 03

2022-06-11 09:57:00 The code family

4.DDL- Table operations - Inquire about

        ① Query all tables in the current database

                show tables;

                

        ② Query table structure

                desc Table name ;

                

        ③ Query the table creation statement of the specified table

                show create table Table name ;

                

5.DDL- Table operations - establish

        ① Create table syntax

                create table Table name (

                 Field 1 Field 1 type [comment Field 1 notes ],

                 Field 2 Field 2 type [comment Field 2 notes ],

                 Field 3 Field 3 type [comment Field 3 notes ],

                ...

                 Field n Field n type [comment Field n notes ]

               ) [comment Table annotation ];

         Be careful : Field n Finally no “,”

         Example :

id                        name                age    gender
1                        Pleasant Sheep                 28        male
2                        lazy sheep                 24        male

                create table tb_user(

                id int comment ' Number ',

                name varchar(50) comment ' full name ',

                age int comment ' Age ',

                gender varchar(1) comment ' Gender '

                ) comment ' User table ';

                

原网站

版权声明
本文为[The code family]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110937111845.html