Mysql (3) operations on mysql-related data TABLES related to data TABLES 1. Command for displaying data TABLES: show tables; command for displaying table information. If you do not have the permission to use a table, the table is not displayed. Command: DESCRIBE tbname; this command displays the structure of a table named tbname. Www.2cto.com 2. create table tbname (column name [1] data type, column name [2] data type, column name [3] data type ); this command is used to create a data table whose tbname is the table name. For example, create table guestbook (visitor VARCHAR (40), comments TEXT, entrydate DATETIME); 3. an important concept of using SELECT results to create a table relational database is that any data is composed of rows and columns, and the results of each SELECT statement are also tables composed of rows and columns. Command: create table test SELECT * FROM test2; this command is used to copy a TABLE by selecting all the content of a TABLE (without the WHERE clause. Command: create table test SELECT * FROM test2 WHERE 0; this command uses a WHERE clause that always fails to CREATE an empty TABLE. 4. modify the structure of a TABLE. alter table is useful. Command: alter table tbname add col_name type. The function of this command is to add a col_name column with the data type as the type for the TABLE tbname. Example: add a column name to the guestbook TABLE; alter table guestbook add name varchar (40); www.2cto.com command: alter table tbname drop col_name; this command is used to delete a column named col_name from the tbname TABLE. For example, to delete a column named alter table guestbook drop name from the guestbook TABLE. Command: alter table tbname modify col_name type; this command is used to modify the Data Type of columns in the table. Example: Change the name data type in the guestbook table. Alter table guestbook modify name TEXT; command: alter table tbname CHANGE oldcol_name newcol_name; this command is used to modify the column name. Example: alter table guestbook CHANGE name username; command: alter table oldtbname RENAME newtbname; this command is used to RENAME a TABLE. Example: change the name of the guestbook table. Alter table guestbook RENAME newguestbook; 5. Run the drop table tb1name [, tb2name,...] command to delete one or more tables. Example: delete a guestbook table. Drop table guestbook; www.2cto.com 6. INSERT command to data table: INSERT [INTO] tbname [(col_name,...)] VALUES (express ,....) this command inserts data into a table. For example, insert data into the guestbook table. Insert into guestbook (visitor, comments, entrydate) VALUES ('sunnyboysac ', 'sunnyboysac', '2017-01-01 '); 7. example of inserting rows selected FROM other tables: insert into tbname (col1, col2) SELECT col3, col4 FROM tb1name; INSERT data queried FROM tb1name INTO columns col1 and col2. Same as: REPLACE