首先的要有個軟件米同,Mac版系統(tǒng)的先要有個MySQL數(shù)據(jù)庫骇扇、桌面MySql圖片。
運行Mysql面粮,里面運行時這樣使用:
創(chuàng)建數(shù)據(jù)庫
-- create database lamco;
使用數(shù)據(jù)庫
-- use lamco;
創(chuàng)建數(shù)據(jù)表
-- create table student
-- (
--????stuid int primary key,
--????stuname varchar(20),
--????stuaddr varchar(200)
-- )
刪除數(shù)據(jù)庫
drop database lamco
刪除數(shù)據(jù)表
drop table student
查詢
-- select * from student
增加
-- insert into student (stuid ,stuname,stuaddr) values(1001,'lisi','bj')
insert into student (stuid,stuname,stuaddr) values(1002,'wangwu','tj')
修改
update student set stuname ='zhaoliu' ,stuaddr='he' where stuid=1002
刪除
delete from student where stuid=1002
create table classes
(
clsid int primary key,
clsname varchar(20)
);
創(chuàng)建外鍵約束
create table student
(
stuid int primary key ,
stuname varchar(20),
stuaddr varchar(20),
clsid int ,
foreign key(clsid)??references classes(clsid)
);
增加
INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....)
修改
UPDATE??table_name??set??column1= value1, column2=value2 where column3=….
刪除
DELETE FROM table_name WHERE column_name = some_value
核心原理: 建庫少孝、建表、建約束但金。增韭山、刪、改冷溃、查钱磅。