MYSQL课堂笔记-表的操作增删改查
MySQL建表笔记
表的创建与增删改查
1.打开MySQL:
mysql -uroot -p(+密码)
C:\Users\Administrator>mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.62 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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.
2.查询数据库:
show databases;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
3.创建一个名为info的库:
create database info;
4.创建一个名为dsj的表:
create table dsj
(
id int unsigned primary key auto_increment,
name varchar (50) not null,
sex enum(‘男’. ‘女’. ‘保密’) default’保密’,
birthday data default ‘2020-01-01’,
phone varchar (11) not null,
email varchar (255) ,
address varchar(255)
);
mysql> create table dsj(
-> dsj_id int unsigned primary key auto_increment,
-> dsj_sex enum("男","女","保密") default"保密",
-> phone varchar(11) not null,
-> address varchar(255)
-> );
Query OK, 0 rows affected (0.14 sec)
5.查看表结构:
describe student;
6.添加表数据:
insert into student(name,sex,birthday,phone,email,address) values (“小明”,“男”,“2020-01-01”,”3194329981@qq.com”,“河南省信阳市淮滨县”) ;
7.查询表数据信息:
select * from student;
8.修改表里的某一坐标信息:
update student set email=‘3194329981@163.com’ where id =1;
9.再次查询表数据信息:
select * from student;
10.删除表里某坐标信息:
delete from student where name !=“张三”;
11.再次查询表数据信息:
selet * from student;
12.删除student表:
drop table student;
13.删除info库:
drop database info;
14.再次查询所有库:
show databases;