【Mysql】mysql基本操作
創(chuàng)建
創(chuàng)建擁有三個字段的表單
create table qq(id int primary key auto_increment ,username varchar(100) ,password varchar(100) )DEFAULT CHARSET=utf8mb4;關于編碼問題,如果顯示問號,則可以在后面加個utf8
CREATE TABLE IF NOT EXISTS `father_module_info` (`id` int(11) DEFAULT NULL,`module_name` char(66) DEFAULT NULL,`show_order` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;刪除:
刪除數據庫:
DROP DATABASE 數據庫名;
刪除表單:
DROP TABLE 表單名;
關于字段
創(chuàng)建表單并添加單個數據
Create table Student( Sno varchar(10) primary key )
向表單中添加字段
alter table Student add Sne varchar(10) not null
alter table Studentadd axba varchar(10) not null
alter table Student add time int notnull
在表單中刪除字段
alter table Student drop column axba;
修改字段
ALTER TABLE user MODIFY email VARCHAR(20) NOT NULL;
關于內容
向單個表添加一行內容
insert INTO user(user, password) values (‘liuxing’,‘123456’);
修改某行中的單個數據
update Student set Sne=‘啊啊啊’ where Sno=‘張三’
刪除某一列的信息:
delete from student where name=’tom’;
創(chuàng)建關聯表
創(chuàng)建user表
創(chuàng)建外聯user的account表
create table account (id int primary key not null,uid int DEFAULT null,money double DEFAULT null,foreign key(uid) REFERENCES user(id) )DEFAULT CHARSET=utf8mb4;總結
以上是生活随笔為你收集整理的【Mysql】mysql基本操作的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 幼儿假期在家表现怎么写大班 幼儿假期在家
- 下一篇: 学校医务室是做什么工作的 学校医务室有什