Database Table operations, database tables
A database is a table container and must belong to a database. the statement specifies the database to which the database belongs. During table operations, the current default database Use db_name is specified; 1. create table tbl_name {Column Structure} [table options] analyze the object data to be saved and what attributes are there. How to save these attributes. For example, class information class number, class start date column definition: column Name Data Type [column attributes (constraints)] simple string type varchar; the first method of date of the date type does not need to specify the database in advance. statement indicates that the second method first specifies the default database 2. view 1> tables Show tables [like 'pattern']; like 'pattern' indicates that the names of tables with certain rules are also applicable to show databases like ['pattern']; 2> Show create table tal_name; tip: You can use \ G as the statement Terminator. Comparison 3> View the table structure (description table structure) Describe tbl_name; Desc tbl_name; table name prefix to differentiate different applications with the same logical table name, add a prefix to the logical table name to form the logical table name. 3. delete the table Drop table tbl_name; no error is returned if the table does not exist: also applicable to database: Drop database if exists db_name; 4. modify the Rename table old tbl_name to tbl_name of a table. You can Rename multiple tables in different databases and move the tables in one database to another, you can use this feature to rename a database. Modify column definitions Add a new column Add delete a column Drop Modify a column definition Modify a column Change old_column new column definition Modify table structure, the above is a sub-command, the upper level is: alter table tbl_name [add | drop | change | modify] Alter table option alter table tbl_name new table Option