mysql基础操作语句,包括数据库的增、删、切换,以及表的增、删、改、查、复制。
创建数据库
mysql> create database tem;
使用数据库
mysql> use tem;
删除数据库
mysql> drop database drop_test;
创建数据表
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)
-> );
创建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)
-> );
插入表数据
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