/*1*/
SELECT COUNT(*) FROM book WHERE AUTHOR ='刘刚';
/*2*/
SELECT * FROM book WHERE publish='人民邮电出版社';
/*3*/
SELECT COUNT(*) FROM book_borrow WHERE CONVERT(borrow_time,DATETIME) LIKE'2024-03-%';
/*4*/
INSERT INTO book(book_name,author,price,publish,book_classify_id,isbn,create_time) VALUES('疑难杂病临证手册(第2版)','余孟学',158,'河南科技出版社','R 医药 卫生','9787534989230',CURTIME());
/*5*/
SELECT user.user_name,book.book_name,book.publish,book_borrow.borrow_time,book_borrow.return_time
FROM book,book_borrow,USER
WHERE user_name='小影'AND user.id=book_borrow.user_id AND book_borrow.book_id=book.id;
/*6*/
CREATE VIEW user_book_borrow_view
AS SELECT user.id,user.login_name,user.user_name,book.book_name,book.publish,book_borrow.borrow_time,book_borrow.return_time
FROM book,USER,book_borrow
WHERE user.id=book_borrow.user_id AND book_borrow.book_id=book.id;
/*7*/
CREATE INDEX booknameindex ON book(book_name);
/*8*/
CREATE INDEX bookpublishnameindex ON book(publish,book_name);
/*9*/
UPDATE USER SET dept_id=3 WHERE user_name='小刚';
/*10*/
DELETE FROM book WHERE book_name LIKE '%经济学%';
/*11*/
DELETE FROM book_borrow
WHERE user_id IN(
SELECT id FROM USER WHERE user.user_name='小影'
)
/*12*/
SELECT book_name
FROM book,book_borrow,book_lose
WHERE book.id=book_borrow.book_id AND book_lose.borrow_id=book_borrow.id;