show databases;
use teacher;
drop teacher;
show engines;
show variables like'storage_engine'%;
default-storage-engine=innodb;
这里以info表为例
desc info;
show databases;
drop info;
insert into info (name,sex,salary) vaules('慧妹妹'.'男'.10000);
select from info ;
update info set sex='男',salary=9999 where name='慧妹妹';
delete from info where id=1;
数据库与Unity连接
导入插件到Unity:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MySql.Data.MySqlClient;
public class Test : MonoBehaviour
{
void Connect()
{
string a = "server=localhost;database=student;userid=root;password=root;";
MySqlConnection con = new MySqlConnection(a);
con.Open();
string sql = "select *from info";
MySqlCommand com = new MySqlCommand(sql, con);
MySqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
int id = reader.GetInt32("id");
string name = reader.GetString("name");
string sex = reader.GetString("sex");
float salary = reader.GetFloat("salary");
print(id + "\t" + name + "\t" + sex + "\t" + salary);
}
reader.Close();
con.Close();
}
void Start()
{
Connect();
}
void Update()
{
}
}
|