SpringBoot记录

时间:2021-7-21 作者:qvyue

1、数据库操作

show databases;
use ;

show DATABASES ;
use spiders;
show tables ;
select *from user;
CREATE TABLE `Testtable` (
    `test_id` BIGINT(32) NOT NULL AUTO_INCREMENT COMMENT '测试ID',
    `test_name` VARCHAR(255) NOT NULL COMMENT '测试名称',
    `test_source` VARCHAR(255) DEFAULT NULL COMMENT '客户来源',
    `test_phone` VARCHAR(255) DEFAULT NULL COMMENT '客户电话',
    `test_level` VARCHAR(255) DEFAULT NULL COMMENT '客户级别',
    PRIMARY KEY (`test_id`)
) ENGINE =INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

select *from Testtable;
#增加列
ALTER TABLE Testtable ADD columnName varchar(30);
#修改列名称
ALTER TABLE Testtable CHANGE columnName test_columnName VARCHAR(30);
#删除列
ALTER TABLE Testtable DROP COLUMN test_columnName;
#批量修改
ALTER TABLE  Testtable CHANGE test_id test_Id BIGINT(12) NOT NULL ,
    CHANGE test_name test_Name VARCHAR(32) NOT NULL ,
    CHANGE test_source test_Source VARCHAR(32) NOT NULL;
INSERT INTO Testtable(test_Id, test_Name, test_Source, test_phone, test_level) VALUES
    ('1', '孔陈亮','易二三', '13143433764', 'iOS开发工程师');

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| spiders            |
| sys                |
+--------------------+
5 rows in set (0.06 sec)

mysql> use spiders;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-------------------+
| Tables_in_spiders |
+-------------------+
| student           |
| user              |
+-------------------+
2 rows in set (0.00 sec)

mysql> select *form student;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'form student' at line 1
mysql> select *from student;
+------------+------+-----+
| id         | name | age |
+------------+------+-----+
| 2019092501 | kcl  |  28 |
+------------+------+-----+
1 row in set (0.00 sec)

mysql> 

//只需要类添加 @RestController 即可,默认类中的方法都会以 json 的格式返回
@RestController
public class HelloController {

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String say() {
        return "Hello Spring Boot";
    }
}

声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:qvyue@qq.com 进行举报,并提供相关证据,工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。