MYSQL的增删改查语句样码

  1. 云栖社区>
  2. 博客>
  3. 正文

MYSQL的增删改查语句样码

天飞 2016-11-11 16:26:00 浏览451
展开阅读全文

慢慢来,慢慢来。。

增:

INSERT INTO person  (person_id, fname, lname, gender, birth_date) VALUES (null,  'William', 'Turner', 'M', '1972-05-27');
INSERT INTO person (person_id, fname, lname, gender, birth_date, street, city, state,  country, postal_code) VALUES (null, 'Susan', 'Smith', 'F', '1975-11-02', '23 Maple St.',  'Arlington', 'VA', 'USA', '20220');

 

删:

DELETE FROM person WHERE person_id = 2;

改:

ALTER TABLE person MODIFY person_id SMALLINT UNSIGNED AUTO_INCREMENT;
UPDATE person SET street = '1225 Tremont St.', city = 'Boston', state = 'MA', country = 'USA', postal_code = '02138' WHERE person_id = 1;

查:

SELECT person_id, fname, lname, birth_date from person WHERE lname = 'Turner';

网友评论

登录后评论
0/500
评论
天飞
+ 关注