Blogger Information
Blog 13
fans 0
comment 0
visits 12217
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
sql语句-3.20日课程作业
小毛的博客
Original
706 people have browsed it

1、执行SQL语句创建数据库及数据表;

2、插入数据行

CREATE DATABASE oa
CHARACTER SET utf8 COLLATE utf8_general_ci;
USE oa;
CREATE TABLE user(
        `id` INT UNSIGNED AUTO_INCREMENT,
        `name` VARCHAR(20) NOT NULL,
        `gender` TINYINT UNSIGNED NOT NULL,
        `age` TINYINT UNSIGNED,
        `tel` VARCHAR(11) NOT NULL,
        `email` VARCHAR(50) NOT NULL,
        `qq` VARCHAR(13),
        `address` VARCHAR(50),
        `birthday` DATE,
        `department` TINYINT UNSIGNED,
    PRIMARY KEY (id)
    )ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT  INTO `user`(`name`,`gender`,`age`,`tel`,`email`,`qq`,`address`,`birthday`,`department`) 
            VALUES('小强',0,123,'122334545','134@qq.com','13441','班尼路','1912-02-12',2);

QQ截图20190320234904.png

总结:

1、创建数据表前,要先选择数据库;

2、表名及字段名使用1左边的点号,数据行中的字符串使用单引号

3、关键词大写,自定义名称小写;

4、枚举类型内需加单引号,易出错,可用tinyint代替


Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post