mysql -h 110.110.110.110 -u root -p
mysql -u root -p
show databases;
结果
+--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | php | | sys | +--------------------+ 5 rows in set (0.00 sec)
use mysql;
show tables;
create database school_info;
drop database school_info;
CREATE TABLE `school_info`.`school` ( `id` bigint(11) UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(200) NULL COMMENT '学校名称', `create_at` bigint(11) NULL, `update_at` bigint(11) NULL, `status` tinyint(4) NULL DEFAULT 0 COMMENT '状态', PRIMARY KEY (`id`) ) ENGINE = InnoDB COMMENT = '学校信息表';
desc school;
结果
+-----------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+---------------------+------+-----+---------+----------------+ | id | bigint(11) unsigned | NO | PRI | NULL | auto_increment | | name | varchar(200) | YES | | NULL | | | create_at | bigint(11) | YES | | NULL | | | update_at | bigint(11) | YES | | NULL | | | status | tinyint(4) | YES | | 0 | | +-----------+---------------------+------+-----+---------+----------------+ 5 rows in set (0.00 sec)
insert into school values(2,"学校3",1625568499,1625568499,1); 或 insert into school(name,create_at,update_at,status) values("学校4",1625568499,1625568499,1);
select * from school;
结果
+----+---------+------------+------------+--------+ | id | name | create_at | update_at | status | +----+---------+------------+------------+--------+ | 1 | 学校1 | 1625568499 | 1625568499 | 1 | | 2 | 学校2 | 1625568499 | 1625568499 | 1 | | 3 | 学校3 | 1625568499 | 1625568499 | 1 | | 4 | 学校4 | 1625568499 | 1625568499 | 1 | +----+---------+------------+------------+--------+ 4 rows in set (0.00 sec)
alter table school add `adress` varchar(200) NULL COMMENT '地址' after `name`;
alter table school drop `adress`;
update school set `name`='学校名称1' where `id`=1;
delete from school where `id`=4;
truncate table school;
drop table if exists school;