当前位置: 首页 >数据库 > mysql20170407代码实现

mysql20170407代码实现

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

mysql20170407代码实现 _ JavaClub全栈架构师技术笔记
| 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 selectedmysql> create table if not exists `subject`(SubjectNo int(11),SubjectName vachar(50),ClassHour int(4),GradeID int(4))comment='课程数据表';ERROR 1046 (3D000): No database selectedmysql> use myschool;Database changedmysql> 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 thatcorresponds to your MySQL server version for the right syntax to use near 'vachar(50),ClassHour int(4),GradeID int(4))comment='课程数据表'' at line 1mysql> 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 thatcorresponds to your MySQL server version for the right syntax to use near 'vachar(50),ClassHour int(4),GradeID int(4))comment='课程数据表'' at line 1mysql> create table if not exists `subject`(SubjectNo int(11),SubjectName varchar(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 columnmysql> create table if not exists grade(GradeID int(11) primary key,GradeName varchar(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'> ;'> ByeC:\Users\Administrator>mysql -uroot -pEnter password: ****Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 9Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> use myschool;Database changedmysql> create table if not exists student(StudentNo int(4) not null comment '学号',LoginPwd varchar(20) default null,StudentName varchar(20) default null comment '学生姓名',Sex tinyint(1) default null comment '性别,取值0或1',GradeId int(11) default null comment '年级编号',Phone varchar(50) not null comment '联系电话,允许为空,即可选输入',Address varchar(255) not null comment '地址,允许为空,即可选输入',BoDate datetime default null comment '出生时间',Email varchar(50)not null comment '邮箱账号,允许为空,即可选输入',IdentityCard varchar(18) default 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 changedmysql> 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 changedmysql> 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 thatcorresponds to your MySQL server version for the right syntax to use near 'subject if exists' at line 1mysql> drop table subject if exists;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds to your MySQL server version for the right syntax to use near 'if exists' at line 1mysql> drop `subject` if exists;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds to your MySQL server version for the right syntax to use near '`subject` if exists' at line 1mysql> 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 thatcorresponds 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 1mysql> 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 '年级编号')engine=MyISAM,comment='课程名称表';ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds 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 1mysql> 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 '年级编号')engine=MyISAM comment='课程名称表';ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds 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 1mysql> 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 '年级编号')engine=MyISAM comment='课程名称表';ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds 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 1mysql> 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 '年级编号')engine=MyISAM comment='课程名称表';ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds to your MySQL server version for the right syntax to use near 'in(0t1) not null comment '课程编号',SubjectName varchar(50) default null com' at line 1mysql> 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 '年级编号')engine=MyISAM,comment='课程名称表'; ;
mysql练习代码

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

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

2 写完保存代码很困难

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

作者:想太多先森
来源链接:https://www.cnblogs.com/xtdxs/p/6680325.html

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaclub.cn/database/117819.html

标签:SQL_syntax
分享给朋友:

“mysql20170407代码实现” 的相关文章

MySQL数据库(基础) 2022年05月16日 21:54:19
MySQL 查询指定时间范围内的数据 2022年06月06日 16:59:25
MySQL 查询结果中增加字段的方法 2022年06月07日 10:05:05
mysql的查询句 2022年06月09日 23:40:52
MYSQL根据日期查询 2022年06月11日 21:03:52
mysql 查询某字段最小的记录 2022年06月12日 13:41:31
mysql查询数据库的名称 2022年06月17日 22:38:25