mysql修改学生信息语句,【MySQL】MySQL基础操作语句

  • Post author:
  • Post category:mysql


mysql基础操作语句,包括数据库的增、删、切换,以及表的增、删、改、查、复制。

创建数据库

mysql> create database tem;

20190221155357978078.png

使用数据库

mysql> use tem;

20190221155358163625.png

删除数据库

mysql> drop database drop_test;

20190221155358304250.png

创建数据表

student表

mysql> CREATE TABLE student (

-> id INT(10) NOT NULL UNIQUE PRIMARY KEY ,

-> name VARCHAR(20) NOT NULL ,

-> sex VARCHAR(4) ,

-> birth YEAR,

-> department VARCHAR(20) ,

-> address VARCHAR(50)

-> );

20190221155358419484.png

创建score表

mysql> CREATE TABLE score (

-> id INT(10) NOT NULL UNIQUE PRIMARY KEY AUTO_INCREMENT ,

-> stu_id INT(10) NOT NULL ,

-> c_name VARCHAR(20) ,

-> grade INT(10)

-> );

20190221155358526906.png

插入表数据

student表

mysql> INSERT INTO student VALUES( 001,‘RooneyMara‘, ‘F‘,1985,‘Psychology‘, ‘American‘);

mysql> INSERT INTO student VALUES( 002,‘ChrisHemsworth‘, ‘M‘,1983,‘CS‘, ‘Australia‘);

mysql> INSERT INTO student VALUES( 003,‘EllenPage‘, ‘F‘,1987,‘Music‘, ‘Canada‘);

mysql> INSERT INTO student VALUES( 004,‘TomHolland‘, ‘M‘,1996,‘CS‘, ‘England‘);

mysql> INSERT INTO student VALUES( 005,‘ScarlettJohansson‘, ‘F‘,1984,‘Music‘, ‘American‘);

mysql> INSERT INTO student VALU