mysql建立資料表

2021-10-04 15:43:52 字數 1030 閱讀 5401

登入:mysql -u root -p

建立資料庫:create database if not existsstudentsdefault charset utf8 collate utf8_general_ci;

使用資料庫:use 資料庫名稱

建立資料表及欄位名: create table if not exists資料庫名字(

idint unsigned auto_increment,

->namevarchar(50) not null,

->ageint(25) not null,

->gendervarchar(50) not null,

->scoreint(25) not null,

-> primary key (id)

-> )engine=innodb default charset=utf8; %注意(分號結尾是執行)

輸入資料:insert into 表名(欄位名)values(字段值)

列入上面:insert into stuinfo(name,***,score,age)valuse(「」,「」,「」,「」),

%注意(,結尾是以下也有關係)

檢視資料表:select * from stuinfo;

查詢所有男生的資料只需要學生的姓名和年齡):select name,age from stuinfo ***="";

查詢及格學生成績資訊(學生成績大於或等於60):select * from stuinfo where score>=「60」;

按照學生的分數進行排序:select * from stuinfo order by score;

所有女生的年齡增加一歲:update stuinfo set age=age+1 where ***=""

%注意「裡面的資料自己設」 欄位名注意自己所設

標題

建立mysql資料表

mysql建表語句 create table if not exists db name.table name colunum1 date not null comment 列欄位說明 colunum2 int 11 not null comment 列欄位說明 colunum3 int 11 no...

MYSQL 建立資料表

rdbms即關聯式資料庫管理系統 relational database management system 的特點 rdbms術語 資料庫 一些關聯的表的集合 資料表 資料的矩陣。等同於簡單的電子 列 同一類資料 行 一組相關資料,稱為乙個記錄 冗餘 儲存量被資料,使系統速度更快。主鍵 唯一。外來...

MySQL 建立資料表

建立mysql資料表需要以下資訊 以下為建立mysql資料表的sql通用語法 create table table name column name column type 以下例子將在 runoob 資料庫中建立資料表runoob tbl runoob tbl runoob id int not ...