1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| [root@server www]# mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 6 Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database newstaff; Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> use newstaff; Database changed MariaDB [newstaff]> create table stafftable ( //按任务需求创建表 -> staffID int auto_increment, //自增 -> username varchar(20), -> sex char(6), -> age int, -> primary key(staffID) -> )engine=innodb default charset=utf8; Query OK, 0 rows affected (0.02 sec)
MariaDB [newstaff]> insert into stafftable(username,sex,age) values('Tom','male',25),('Mary','female',30); Query OK, 2 rows affected (0.05 sec) Records: 2 Duplicates: 0 Warnings: 0
MariaDB [newstaff]> desc stafftable; +----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+----------------+ | staffID | int(11) | NO | PRI | NULL | auto_increment | | username | varchar(20) | YES | | NULL | | | sex | char(6) | YES | | NULL | | | age | int(11) | YES | | NULL | | +----------+-------------+------+-----+---------+----------------+ 4 rows in set (0.00 sec)
MariaDB [newstaff]> select * from stafftable; +---------+----------+--------+------+ | staffID | username | sex | age | +---------+----------+--------+------+ | 1 | Tom | male | 25 | | 2 | Mary | female | 30 | +---------+----------+--------+------+ 2 rows in set (0.01 sec)
MariaDB [newstaff]> quit Bye [root@server www]#
|