• MYSQL(一)


    1.Drop
    DROP [TEMPORARY] TABLE [IF EXISTS]
        tbl_name [, tbl_name] ...
        [RESTRICT | CASCADE]
    示例:DROP TABLE table;
    2.vchar(256)
    在创建表时正确的数据类型为char(256),而且最大长度限制为255,改为char(255)
    3.PRIMARY KEY
    在一个表中,为PRIMARY KEY的字段只能有一个
    4.建表示例
    mysql> create table MyClass(
    > id int(4) not null primary key auto_increment,
    > name char(20) not null,
    > sex int(4) not null default '0',
    > degree double(16,2));
    5.防止字段重复
    ALTER TABLE `TableName` 
     ADD UNIQUE INDEX IndexName(`FieldName`);
    6.SHOW
    show databases;
    show tables from db_name;
    show columns from table_name from db_name;
    show index from talbe_name [from db_name];
    show status;
    show variables;
    show [full] processlist;
    show table status [from db_name];
    show grants for user;
    7.事务加X锁(排他锁)
    SET TRANSACTION ISOLATION LEVEL REPEATABLE READ BEGIN TRAN
    SELECT * FROM bigtable
    UPDATE bigtable
    SET col = 0
    WHERE keycolumn = 100
    8.事务
    begin 开始事务
    commit 提交事务
    rollback 回滚事务
    9.引擎与自动回滚
    我的MYSQL默认引擎为InnoDB
    我们可以通过SHOW ENGINES;查看
    InnoDB默认自动回滚事务,参考http://www.yiibai.com/mysql5/constraints.html
    10.UPDATE语句
    单表Update
    1 UPDATE [LOW_PRIORITY] [IGNORE] tbl_name  
    2 SET col_name1=expr1 [, col_name2=expr2 ...]  
    3 [WHERE where_definition]  
    4 [ORDER BY ...]  
    5 [LIMIT row_count] 
    多表Update
    1 UPDATE [LOW_PRIORITY] [IGNORE] table_references  
    2 SET col_name1=expr1 [, col_name2=expr2 ...]  
    3 [WHERE where_definition]
  • 相关阅读:
    Codeforces Round #251 (Div. 2) A
    topcoder SRM 623 DIV2 CatAndRat
    topcoder SRM 623 DIV2 CatchTheBeatEasy
    topcoder SRM 622 DIV2 FibonacciDiv2
    topcoder SRM 622 DIV2 BoxesDiv2
    Leetcode Linked List Cycle II
    leetcode Linked List Cycle
    Leetcode Search Insert Position
    关于vim插件
    Codeforces Round #248 (Div. 2) B. Kuriyama Mirai's Stones
  • 原文地址:https://www.cnblogs.com/ketmales/p/2945247.html
Copyright © 2020-2023  润新知