《MySQL核心技术手册》--第1章--xxx

命令行输入:

mysql -u root -p

然后,输入密码

show databases;

创建数据库

create database bookstore;

切换数据库

user bookstore;
创建表
create table books(
book_id int, 
title varchar(50),
author varchar(50)
);
查看刚才创建的表
describe books;
对表的一些修改操作
alter table books
change column book_id book_id int auto_increment primary key,
change column author author_id int,
add column description text,
add column genre enum ('novel', 'poetry', 'drama'),
add column publisher_id int,
add column pub_year varchar(4),
add column isbn varchar(20);
创建authors表
create table authors(
author_id int auto_increment primary key,
author_last varchar(50),
author_first varchar(50),
country varchar(50)
);

显示所有表
show tables;

insert into authors (author_last, author_first, country) values ('greene', 'graham', 'united kingdom');


select last_insert_id();


insert into books (title, author_id, isbn, genre, pub_year) values ('the end of the affair', 1, '00054542124','novel','1951');



























你可能感兴趣的:(读书笔记)