• 吴裕雄--天生自然PHP-MySQL-JavaScript学习笔记:MySQL入门


    this is "meaningless gibberish to mysql" c
    CREATE TABLE classics (
     author VARCHAR(128),
     title VARCHAR(128),
     type VARCHAR(16),
     year CHAR(4)) ENGINE InnoDB;
    USE publications;
    CREATE TABLE classics (
    author VARCHAR(128),
    title VARCHAR(128),
    type VARCHAR(16),
    year CHAR(4)) ENGINE InnoDB;
    DESCRIBE classics;
    ALTER TABLE classics ADD id INT UNSIGNED
      NOT NULL AUTO_INCREMENT KEY;
    CREATE TABLE classics (
     author VARCHAR(128),
     title VARCHAR(128),
     type VARCHAR(16),
     year CHAR(4),
     id INT UNSIGNED NOT NULL AUTO_INCREMENT KEY) ENGINE InnoDB;
    ALTER TABLE classics DROP id;
    INSERT INTO classics(author, title, type, year)
     VALUES('Mark Twain','The Adventures of Tom Sawyer','Fiction','1876');
    INSERT INTO classics(author, title, type, year)
     VALUES('Jane Austen','Pride and Prejudice','Fiction','1811');
    INSERT INTO classics(author, title, type, year)
     VALUES('Charles Darwin','The Origin of Species','Non-Fiction','1856');
    INSERT INTO classics(author, title, type, year)
     VALUES('Charles Dickens','The Old Curiosity Shop','Fiction','1841');
    INSERT INTO classics(author, title, type, year)
     VALUES('William Shakespeare','Romeo and Juliet','Play','1594');
    CREATE TABLE disposable(trash INT);
    DESCRIBE disposable;
    DROP TABLE disposable;
    SHOW tables;
    ALTER TABLE classics ADD INDEX(author(20));
    ALTER TABLE classics ADD INDEX(title(20));
    ALTER TABLE classics ADD INDEX(category(4));
    ALTER TABLE classics ADD INDEX(year);
    DESCRIBE classics;
    ALTER TABLE classics ADD INDEX(author(20));
    CREATE INDEX author ON classics (author(20));
    CREATE TABLE classics (
     author VARCHAR(128),
     title VARCHAR(128),
     category VARCHAR(16),
     year SMALLINT,
     INDEX(author(20)),
     INDEX(title(20)),
     INDEX(category(4)),
     INDEX(year)) ENGINE InnoDB;
    ALTER TABLE classics ADD isbn CHAR(13);
    UPDATE classics SET isbn='9781598184891' WHERE year='1876';
    UPDATE classics SET isbn='9780582506206' WHERE year='1811';
    UPDATE classics SET isbn='9780517123201' WHERE year='1856';
    UPDATE classics SET isbn='9780099533474' WHERE year='1841';
    UPDATE classics SET isbn='9780192814968' WHERE year='1594';
    ALTER TABLE classics ADD PRIMARY KEY(isbn);
    DESCRIBE classics;
    CREATE TABLE classics (
     author VARCHAR(128),
     title VARCHAR(128),
     category VARCHAR(16),
     year SMALLINT,
     isbn CHAR(13),
     INDEX(author(20)),
     INDEX(title(20)),
     INDEX(category(4)),
     INDEX(year),
     PRIMARY KEY (isbn)) ENGINE InnoDB;
    ALTER TABLE classics ADD FULLTEXT(author,title);
    SELECT author,title FROM classics;
    SELECT title,isbn FROM classics;
    SELECT COUNT(*) FROM classics;
    INSERT INTO classics(author, title, category, year, isbn)
     VALUES('Charles Dickens','Little Dorrit','Fiction','1857',
     '9780141439969');
    SELECT author FROM classics;
    SELECT DISTINCT author FROM classics;
    DELETE FROM classics WHERE title='Little Dorrit';
    SELECT author,title FROM classics WHERE author="Mark Twain";
    SELECT author,title FROM classics WHERE isbn="9781598184891 ";
    SELECT author,title FROM classics WHERE author LIKE "Charles%";
    SELECT author,title FROM classics WHERE title LIKE "%Species";
    SELECT author,title FROM classics WHERE title LIKE "%and%";
    SELECT author,title FROM classics LIMIT 3;
    SELECT author,title FROM classics LIMIT 1,2;
    SELECT author,title FROM classics LIMIT 3,1;
    SELECT author,title FROM classics
     WHERE MATCH(author,title) AGAINST('and');
    SELECT author,title FROM classics
     WHERE MATCH(author,title) AGAINST('old shop');
    SELECT author,title FROM classics
     WHERE MATCH(author,title) AGAINST('tom sawyer');
    SELECT author,title FROM classics
     WHERE MATCH(author,title)
     AGAINST('+charles -species' IN BOOLEAN MODE);
    SELECT author,title FROM classics
     WHERE MATCH(author,title)
     AGAINST('"origin of"' IN BOOLEAN MODE);
    UPDATE classics SET author='Mark Twain (Samuel Langhorne Clemens)'
     WHERE author='Mark Twain';
    UPDATE classics SET category='Classic Fiction'
     WHERE category='Fiction';
    SELECT author,title FROM classics ORDER BY author;
    SELECT author,title FROM classics ORDER BY title DESC;
    CREATE TABLE customers (
     name VARCHAR(128),
     isbn VARCHAR(13),
     PRIMARY KEY (isbn)) ENGINE InnoDB;
    INSERT INTO customers(name,isbn)
     VALUES('Joe Bloggs','9780099533474');
    INSERT INTO customers(name,isbn)
     VALUES('Mary Smith','9780582506206');
    INSERT INTO customers(name,isbn)
     VALUES('Jack Wilson','9780517123201');
    SELECT * FROM customers;
    SELECT name,author,title from customers,classics
     WHERE customers.isbn=classics.isbn;
    SELECT author,title FROM classics WHERE
     author LIKE "Charles%" AND author LIKE "%Darwin";
    SELECT author,title FROM classics WHERE
     author LIKE "%Mark Twain%" OR author LIKE "%Samuel Langhorne Clemens%";
    SELECT author,title FROM classics WHERE
     author LIKE "Charles%" AND author NOT LIKE "%Darwin";
    meaningless gibberish to mysql c
  • 相关阅读:
    反射
    EFCore笔记之异步查询
    EFCore笔记之查询数据
    Json扩展 (转)
    C语言学习笔记之成员数组和指针
    asp中cookie欺骗/注入原理与防范
    简单的php Mysql类(查询 删除 更新)
    PHP四舍五入精确小数位及取整
    CentOS中配置LNMP环境打开提示File not found
    WIN中SharePoint Server 2010 入门安装部署详解
  • 原文地址:https://www.cnblogs.com/tszr/p/12380957.html
Copyright © 2020-2023  润新知