MySQL建库建表(初识MySQL)
用以保存MySQL的最基礎(chǔ)語(yǔ)法
(以SQLyog展現(xiàn)效果)
數(shù)據(jù)庫(kù)相關(guān)
創(chuàng)建數(shù)據(jù)庫(kù):
create database csdn_test;
create database 數(shù)據(jù)庫(kù)名;
使用 / 跳轉(zhuǎn)數(shù)據(jù)庫(kù):
use csdn_test;
use 數(shù)據(jù)庫(kù)名;
刪除數(shù)據(jù)庫(kù):
drop database csdn_test;
drop database 數(shù)據(jù)庫(kù)名 ;
(內(nèi)容過(guò)于兇殘不進(jìn)行展示)
表單相關(guān)
建表:
create table student(
sid int primary key auto_increment,
sname varchar(20),
ssex varchar(6)
);
create table 表單名(
列名1 數(shù)據(jù)類(lèi)型(int省略長(zhǎng)度) primary key(主鍵) auto_increment(自增列),
列名2 數(shù)據(jù)類(lèi)型(預(yù)留長(zhǎng)度),
列名3 數(shù)據(jù)類(lèi)型(預(yù)留長(zhǎng)度)
);
刪除表單:
drop table student;
drop table 表單名;
(內(nèi)容過(guò)于兇殘不進(jìn)行展示)
那么今天的內(nèi)容暫時(shí)就先這些。一是因?yàn)閯傞_(kāi)始CSDN的嘗試,使用并不熟練,邊學(xué)邊用;另一個(gè)也是對(duì)于MySQL語(yǔ)句的掌握還很不足,在一邊學(xué)習(xí)的過(guò)程中去逐步進(jìn)行完善。
(以下內(nèi)容為次日補(bǔ)充)
插入數(shù)據(jù):
insert into student values(‘1’,‘張三’,‘male’);
insert into student (ssex,sname,sid) values(‘female’,‘小花’,‘2’);
insert into 表單名 values(數(shù)據(jù)1,數(shù)據(jù)2,數(shù)據(jù)3);
insert into 表單名(列名1,列名2,列名3) values(數(shù)據(jù)1,數(shù)據(jù)2,數(shù)據(jù)3);
刪除數(shù)據(jù):
delete from student where ssex = ‘female’;
delete from 表單名 where 條件;
修改數(shù)據(jù):
update student set ssex = ‘female’ where sname = ‘張三’;
update 表單名 set 屬性名= 值 where 屬性名=值;
查詢表單所有數(shù)據(jù):
select * from student;
select * from 表單名;
(內(nèi)容過(guò)于繁雜,下篇初表)
總結(jié)
以上是生活随笔為你收集整理的MySQL建库建表(初识MySQL)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: gitee使用教程(超详解)
- 下一篇: 猪毛疯是什么