zoukankan      html  css  js  c++  java
  • mysql20170407代码实现

    今天用了一会儿sqlyog,感觉还是会让人懒惰,所以选择了ms-dos环境,感觉不错,原生态,敲着很爽;

    | test01             |
    | tree               |
    | world              |
    +--------------------+
    18 rows in set (0.00 sec)
    
    mysql> create database if not exists myschool;
    Query OK, 1 row affected (0.00 sec)
    
    mysql> show databases
        -> ;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | bdqn               |
    | mybatis            |
    | myschool           |
    | myschool2          |
    | mysql              |
    | news               |
    | performance_schema |
    | sakila             |
    | school             |
    | smbms              |
    | smbmsdemo          |
    | ssh01              |
    | t09                |
    | t12                |
    | test               |
    | test01             |
    | tree               |
    | world              |
    +--------------------+
    19 rows in set (0.00 sec)
    
    mysql> create table if not exists `subject`()
        ->
        -> ;
    ERROR 1046 (3D000): No database selected
    mysql> create table if not exists `subject`(SubjectNo int(11),SubjectName vachar
    (50),ClassHour int(4),GradeID int(4))comment='课程数据表';
    ERROR 1046 (3D000): No database selected
    mysql> use myschool;
    Database changed
    mysql> create table if not exists `subject`(SubjectNo int(11),SubjectName vachar
    (50),ClassHour int(4),GradeID int(4))comment='课程数据表';
    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 'vacha
    r(50),ClassHour int(4),GradeID int(4))comment='课程数据表'' at line 1
    mysql> create table if not exists `subject`(SubjectNo int(11),SubjectName vachar
    (50),ClassHour int(4),GradeID int(4))comment='课程数据表';
    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 'vacha
    r(50),ClassHour int(4),GradeID int(4))comment='课程数据表'' at line 1
    mysql> create table if not exists `subject`(SubjectNo int(11),SubjectName varcha
    r(50),ClassHour int(4),GradeID int(4))comment='课程数据表';
    Query OK, 0 rows affected (2.20 sec)
    
    mysql> select * from subject
        -> ;
    Empty set (0.00 sec)
    
    mysql> select * from `subject`;
    Empty set (0.00 sec)
    
    mysql> insert into `subject` values('1','高等数学-1','120','1');
    Query OK, 1 row affected (0.14 sec)
    
    mysql> insert into `subject` values('2','高等数学-2','110','2');
    Query OK, 1 row affected (0.13 sec)
    
    mysql> insert into `subject` values('3','高等数学-3','100','3');
    Query OK, 1 row affected (0.13 sec)
    
    mysql> insert into `subject` values('4','高等数学-4','130','4');
    Query OK, 1 row affected (0.14 sec)
    
    mysql> insert into `subject` values('5','C语言-1','120','1');
    Query OK, 1 row affected (0.14 sec)
    
    mysql> insert into `subject` values('6','C语言-2','110','2');
    Query OK, 1 row affected (0.13 sec)
    
    mysql> select * from `subject`;
    +-----------+-------------+-----------+---------+
    | SubjectNo | SubjectName | ClassHour | GradeID |
    +-----------+-------------+-----------+---------+
    |         1 | 高等数学-1  |       120 |       1 |
    |         2 | 高等数学-2  |       110 |       2 |
    |         3 | 高等数学-3  |       100 |       3 |
    |         4 | 高等数学-4  |       130 |       4 |
    |         5 | C语言-1     |       120 |       1 |
    |         6 | C语言-2     |       110 |       2 |
    +-----------+-------------+-----------+---------+
    6 rows in set (0.00 sec)
    
    mysql> create table if not exists grade;
    ERROR 1113 (42000): A table must have at least 1 column
    mysql> create table if not exists grade(GradeID int(11) primary key,GradeName va
    rchar(50))comment='年级表';
    Query OK, 0 rows affected (2.22 sec)
    
    mysql> insert into grade values('1','大一');
    Query OK, 1 row affected (0.11 sec)
    
    mysql> insert into grade values('2','大二');
    Query OK, 1 row affected (0.13 sec)
    
    mysql> insert into grade values('3','大三');
    Query OK, 1 row affected (0.13 sec)
    
    mysql> insert into grade values('1','大四');
    ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'
    mysql> insert into grade values('4','大四');
    Query OK, 1 row affected (0.13 sec)
    
    mysql> select * from grade;
    +---------+-----------+
    | GradeID | GradeName |
    +---------+-----------+
    |       1 | 大一      |
    |       2 | 大二      |
    |       3 | 大三      |
    |       4 | 大四      |
    +---------+-----------+
    4 rows in set (0.00 sec)
    
    mysql> create table if not exists student(StudentNo int(4) not null comment '学
    号'),,,Loginarchar(20) default null,StudentName varchar(20) default null comment
     '学ent '学生姓名',,,,,
        '> ;
        '> ;
        '> kdjsf;a
        '> ;
        '> Bye
    
    C:UsersAdministrator>mysql -uroot -p
    Enter password: ****
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 9
    Server version: 5.5.54-log MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> use myschool;
    Database changed
    mysql> create table if not exists student(StudentNo int(4) not null comment '学
    号',LoginPwd varchar(20) default null,StudentName varchar(20) default null comme
    nt '学生姓名',Sex tinyint(1) default null comment '性别,取值0或1',GradeId int(1
    1) default null comment '年级编号',Phone varchar(50) not null comment '联系电话
    ,允许为空,即可选输入',Address varchar(255) not null comment '地址,允许为空,
    即可选输入',BornDate datetime default null comment '出生时间',Email varchar(50)
    not null comment '邮箱账号,允许为空,即可选输入',IdentityCard varchar(18) defau
    lt null comment '身份证号')comment='学生类';
    Query OK, 0 rows affected (0.53 sec)
    
    mysql> select * from student;
    Empty set (0.02 sec)
    
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | bdqn               |
    | mybatis            |
    | myschool           |
    | myschool2          |
    | mysql              |
    | news               |
    | performance_schema |
    | sakila             |
    | school             |
    | smbms              |
    | smbmsdemo          |
    | ssh01              |
    | t09                |
    | t12                |
    | test               |
    | test01             |
    | tree               |
    | world              |
    +--------------------+
    19 rows in set (0.00 sec)
    
    mysql> use myschool;
    Database changed
    mysql> select * from student;
    Empty set (0.00 sec)
    
    mysql> show tables;
    +--------------------+
    | Tables_in_myschool |
    +--------------------+
    | grade              |
    | student            |
    | subject            |
    +--------------------+
    3 rows in set (0.00 sec)
    
    mysql> select * from subject;
    +-----------+-------------+-----------+---------+
    | SubjectNo | SubjectName | ClassHour | GradeID |
    +-----------+-------------+-----------+---------+
    |         1 | 高等数学-1  |       120 |       1 |
    |         2 | 高等数学-2  |       110 |       2 |
    |         3 | 高等数学-3  |       100 |       3 |
    |         4 | 高等数学-4  |       130 |       4 |
    |         5 | C语言-1     |       120 |       1 |
    |         6 | C语言-2     |       110 |       2 |
    +-----------+-------------+-----------+---------+
    6 rows in set (0.00 sec)
    
    mysql> use myschool;
    Database changed
    mysql> show tables;
    +--------------------+
    | Tables_in_myschool |
    +--------------------+
    | grade              |
    | student            |
    | subject            |
    +--------------------+
    3 rows in set (0.00 sec)
    
    mysql> drop subject if exists;
    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 'subje
    ct if exists' at line 1
    mysql> drop table subject if exists;
    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 'if ex
    ists' at line 1
    mysql> drop `subject` if exists;
    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 '`subj
    ect` if exists' at line 1
    mysql> drop table if exists subject;
    Query OK, 0 rows affected (0.47 sec)
    
    mysql> show tables;
    +--------------------+
    | Tables_in_myschool |
    +--------------------+
    | grade              |
    | student            |
    +--------------------+
    2 rows in set (0.00 sec)
    
    mysql> create table if not exists subject(SubjectNo in(11) not null comment '课
    程编号',SubjectName varchar(50) default null comment '课程名称',ClassHour int(4)
     default null comment '学时',GradeID int(4) default null comment '年级编号';
    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 'in(11
    ) not null comment '课程编号',SubjectName varchar(50) default null comm' at line
     1
    mysql> create table if not exists subject(SubjectNo in(11) not null comment '课
    程编号',SubjectName varchar(50) default null comment '课程名称',ClassHour int(4)
     default null comment '学时',GradeID int(4) default null comment '年级编号')engi
    ne=MyISAM,comment='课程名称表';
    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 'in(11
    ) not null comment '课程编号',SubjectName varchar(50) default null comm' at line
     1
    mysql> create table if not exists subject(SubjectNo in(11) not null comment '课
    程编号',SubjectName varchar(50) default null comment '课程名称',ClassHour int(4)
     default null comment '学时',GradeID int(4) default null comment '年级编号')engi
    ne=MyISAM comment='课程名称表';
    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 'in(11
    ) not null comment '课程编号',SubjectName varchar(50) default null comm' at line
     1
    mysql> create table if not exists subject(SubjectNo in(11) not null comment '课
    程编号',SubjectName varchar(50) default null comment '课程名称',ClassHour int(4)
     default null comment '学时',GradeID int(4) default null comment '年级编号')engi
    ne=MyISAM comment='课程名称表';
    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 'in(11
    ) not null comment '课程编号',SubjectName varchar(50) default null comm' at line
     1
    mysql> create table if not exists subject(SubjectNo in(0t1) not null comment '课
    程编号',SubjectName varchar(50) default null comment '课程名称',ClassHour int(4)
     default null comment '学时',GradeID int(4) default null comment '年级编号')engi
    ne=MyISAM comment='课程名称表';
    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 'in(0t
    1) not null comment '课程编号',SubjectName varchar(50) default null com' at line
     1
    mysql> create table if not exists subject(SubjectNo in(11) not null comment '课
    程编号',SubjectName varchar(50) default null comment '课程名称',ClassHour int(4)
     default null comment '学时',GradeID int(4) default null comment '年级编号')engi
    ne=MyISAM,comment='课程名称表'; ;
    mysql练习代码

     当然ms-dos的缺点也很多:

    1 不好编辑,特别是错了的时候,会乱

    2 写完保存代码很困难

    3 每次语句写完都要打分号

  • 相关阅读:
    vue-cli生成的重要代码详解
    vuex初探
    vue-router笔记
    新技术的学习
    图片优化方法(有时间看看)
    关于老教授之家项目的思考 && 中国互联网+大赛培训
    If you are tired...
    微信公众平台开发初探
    winscp介绍与使用
    获取当前服务器信息
  • 原文地址:https://www.cnblogs.com/xtdxs/p/6680325.html
Copyright © 2011-2022 走看看