美文网首页
SpringBoot记录

SpringBoot记录

作者: 獨荹儛臨 | 来源:发表于2020-04-23 17:08 被阅读0次

    1、数据库操作

    show databases;
    use <database>;

    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";
        }
    }
    
    

    相关文章

      网友评论

          本文标题:SpringBoot记录

          本文链接:https://www.haomeiwen.com/subject/gbnbihtx.html