- Create message database: LIUYANDB;
- Create a message form Liuyan in the LIUYANDB database, with the following structure:
Table name |
Liuyan |
Message Information Form |
Serial number |
Field name |
Field description |
Type |
Property |
Note |
1 |
Id |
Number |
Int (4) |
Non-empty |
Primary key, self-increment 1 |
2 |
Title |
Title |
varchar (32) |
Non-empty |
|
3 |
Author |
Author |
varchar (16) |
Can be empty |
|
4 |
Addtime |
Message time |
Datatime |
Non-empty |
|
5 |
Content |
Message content |
Text |
Non-empty |
|
6 |
Isdelete |
Whether to delete |
char (1) |
Non-empty |
Default value 0 |
- Add a column status at the end of the message list (status char (1) default value is 0)
- Modify the message table author default value is ' Youku ', set to non-empty
- Remove the Isdelete field from the Liuyan table
- Add >5 test data to the message table
- Required to change the value of author field to admin in information with ID value greater than 3
- Delete the data with ID number 4.
Additional questions:
- Add >15 test data to the message table, require three users to add
- Check all message information
- Query a user's message information.
- Queries all data, sorted by time in descending order.
- Get message with ID from 2 to 6 and sort by time descending
- Count the number of messages left by each user and sort them from small to large.
- Change the author of two data with ID 8 and 9 to ' Doudou '.
- Take out the latest three messages. (use limit).
- Query message contains "D" letter message, and according to the message time from small to large sort
- Delete "Author" duplicate data and retain one author with the largest ID
MySQL Exercises "One" additional question