首页 > 代码库 > mysql20170407代码实现
mysql20170407代码实现
今天用了一会儿sqlyog,感觉还是会让人懒惰,所以选择了cmdos环境,感觉不错,原生态,敲着很爽;
| 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 ‘地址,允许为空,即可选输入‘,BornDate 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=‘课程名称表‘; ;
mysql20170407代码实现
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。