Get the App
SLTechnology News&Howtos  ›  Database  › 

Mysql analysis with examples

Shulou Source: shulou.com Published: 2022-06-01 20:32:20 09月16日 Update

The following content mainly brings you mysql example analysis, the knowledge mentioned here, which is slightly different from books, is summed up by professional and technical personnel in the process of contact with users, and has a certain value of experience sharing, hoping to bring help to the majority of readers.

Mysql installation is not introduced, mysql-uroot-p

Mysql > show databases

+-+

| | Database |

+-+

| | information_schema |

| | mysql |

| | performance_schema |

| | test |

+-+

4 rows in set (0.02 sec)

Create a tabl

Mysql > create database publications

Query OK, 1 row affected (0.00 sec)

View the table and use the

Mysql > show databases

+-+

| | Database |

+-+

| | information_schema |

| | mysql |

| | performance_schema |

| | publications |

| | test |

+-+

5 rows in set (0.00 sec)

Mysql > use publications

Database changed

Create a database management user

Mysql > * grant all on publications. To 'huang'@'localhost' identified by "123456"

Query OK, 0 rows affected (0.00 sec)

Update permissions

Mysql > flush privileges

Query OK, 0 rows affected (0.00 sec)

Create a table to view a table

Mysql > create table classics (author varchar, title varchar, type varchar, year char); * *

Query OK, 0 rows affected (0.01 sec)

Mysql > desc classics

+-+ +

| | Field | Type | Null | Key | Default | Extra | |

+-+ +

| | author | varchar (128) | YES | | NULL |

| | title | varchar (128) | YES | | NULL |

| | type | varchar (16) | YES | | NULL |

| | year | char (4) | YES | | NULL |

+-+ +

4 rows in set (0.00 sec)

Delete tabl

Mysql > drop table classics

Query OK, 0 rows affected (0.00 sec)

Create the table again and add the id option

Mysql > create table classics (author varchar 128128, title varchar 128128, type varchar 16), year char 4, id INT unsigned not null auto_increment key) ENGINE MyISAM

Query OK, 0 rows affected (0.01 sec)

Delete id option

Mysql > alter table classics drop id

Query OK, 0 rows affected (0.00 sec)

Records: 0 Duplicates: 0 Warnings: 0

Insert data into the table

Mysql > insert into classics (author,title,type,year)

-> values ("mark twain", "muguangzhicheng", 'fiction', "1876")

Query OK, 1 row affected (0.00 sec)

Mysql > insert into classics (author,title,type,year) values ("frank hello", "xianglongshibazhang", 'fiction', "1856")

Query OK, 1 row affected (0.00 sec)

Mysql > insert into classics (author,title,type,year) values ("world go", "shgendiaoxialv", 'play', "1841")

Query OK, 1 row affected (0.00 sec)

Mysql > insert into classics (author,title,type,year) values ("nale", "xiakexing", 'play', "1541")

Query OK, 1 row affected (0.00 sec)

Mysql > select * from classics

+-+

| | author | title | type | year | |

+-+

| | mark twain | muguangzhicheng | fiction | 1876 | |

| | frank hello | xianglongshibazhang | fiction | 1856 | |

| | world go | shgendiaoxialv | play | 1841 | |

| | nale | xiakexing | play | 1541 | |

+-+

4 rows in set (0.00 sec)

Change the table name

Mysql > alter table classics rename pre1900

Query OK, 0 rows affected (0.00 sec)

Mysql > show tables

+-- +

| | Tables_in_publications |

+-- +

| | pre1900 |

+-- +

1 row in set (0.00 sec)

For the above example analysis of mysql, if you have more to know, you can continue to pay attention to the innovation of our industry, if you need to get professional answers, you can contact the pre-sale and after-sale on the official website. I hope this article can bring you some knowledge updates.

Tags: Analysis professional data user knowledge update different below books people value content again available in name technology database more permissions experience Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info OPPO Reno MariaDB vpn Docker