0% found this document useful (0 votes)
2 views2 pages

Smart Ebook Library SQL Code

The document provides SQL code for creating a database named 'library' and a table 'ebooks' to store information about ebooks. It includes commands for inserting sample records, displaying all records, searching for specific titles or authors, updating a book record, and deleting a book record. This code serves as a foundational structure for managing a smart ebook library.

Uploaded by

rooshaannasir70
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Smart Ebook Library SQL Code

The document provides SQL code for creating a database named 'library' and a table 'ebooks' to store information about ebooks. It includes commands for inserting sample records, displaying all records, searching for specific titles or authors, updating a book record, and deleting a book record. This code serves as a foundational structure for managing a smart ebook library.

Uploaded by

rooshaannasir70
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

SQL Code for Smart Ebook Library

-- Create Database

CREATE DATABASE library;

-- Use the database

USE library;

-- Create Table

CREATE TABLE ebooks (

book_id INT AUTO_INCREMENT PRIMARY KEY,

title VARCHAR(100),

author VARCHAR(100),

genre VARCHAR(50),

year INT

);

-- Insert Sample Records

INSERT INTO ebooks (title, author, genre, year) VALUES

('The Alchemist', 'Paulo Coelho', 'Fiction', 1988),

('Python Programming', 'John Zelle', 'Education', 2010),

('Digital Fortress', 'Dan Brown', 'Thriller', 1998);

-- Display All Records

SELECT * FROM ebooks;

-- Search Records by title or author (example)

SELECT * FROM ebooks WHERE title LIKE '%Python%' OR author LIKE '%Dan%';

-- Update a Book Record

UPDATE ebooks SET title='Python Crash Course', author='Eric Matthes', genre='Education',

year=2019 WHERE book_id=2;


-- Delete a Book Record

DELETE FROM ebooks WHERE book_id=1;

You might also like