新聞中心
以下的文章主要介紹的是MySQL數(shù)據(jù)庫(kù)的基本知識(shí),其中包括對(duì)MySQL數(shù)據(jù)庫(kù)的創(chuàng)建,以及對(duì)一些相關(guān)的數(shù)據(jù)類(lèi)型描述,其中還涉及到表的創(chuàng)建,以下就是文章的詳細(xì)內(nèi)容描述,望你會(huì)有所收獲。

站在用戶的角度思考問(wèn)題,與客戶深入溝通,找到云巖網(wǎng)站設(shè)計(jì)與云巖網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類(lèi)型包括:成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名申請(qǐng)、網(wǎng)站空間、企業(yè)郵箱。業(yè)務(wù)覆蓋云巖地區(qū)。
MySQL數(shù)據(jù)庫(kù)安裝 ***改變字符集UTF8
創(chuàng)建數(shù)據(jù)庫(kù)
- create database mydata;
- use mydata;
數(shù)據(jù)類(lèi)型 int double char varchar datetime longtext
創(chuàng)建表 create table dept
- (
- deptno int primary key,
- dname varchar(14),
- loc varchar(13)
- );
- create table emp
- (
- empno int primary key,
- ename varchar(10),
- job varchar(15),
- mgr int,
- hiredate datetime,
- sal double,
- deptno int,
- foreign key (deptno) references dept(deptno)
- );
MySQL數(shù)據(jù)庫(kù)執(zhí)行腳本文件.sql \. 文件路徑 或 source 文件路徑
?
sql文件中 -- 注釋
MySQL管理軟件 MySQL administrator,toad for MySQL
查看數(shù)據(jù)庫(kù) show databases;
查看表 show tables;
查看表結(jié)構(gòu) desc dept;
插入數(shù)據(jù)
- intsert into dept values(1,'a','a');
- commit;
分頁(yè) select * from dept order by deptno desc limit 3,2; (從第三條往后數(shù)兩條)
自增 create table article
- (
- id int primary key auto_increment,
- title vachar(255)
- );
- insert into article values(null,'a');
- insert into article(title) values('c');
日期處理
獲取當(dāng)前日期 select now();
轉(zhuǎn)化字符串 select date_format(now(),'%Y-%m-%d %H:%i:%s');
- jdbc連接MySQL
- Connection conn=null;
- Statement stmt=null;
- ResultSet rs=null;
- try{
- Class.forName("com.MySQL.jdbc.Driver").newInstance();
- conn=DriverManager.getConnection("jdbc:MySQL://localhost/test? user=root&password=root");
- stmt=conn.createStatement();
- rs = stamt.executeQuery(sql);
- }
- catch(Exception e){}
- finally{
- try{
- if(rs!=null){rs.close; rs=null;}
- if(stat!=null){stat.close; stat=null;}
- if(conn!=null){conn.close; conn=null;}
- }
- catch(SQLException e){
- e.printStackTrace();
- }
- }
以上的相關(guān)內(nèi)容就是對(duì)MySQL數(shù)據(jù)庫(kù)知識(shí)的介紹,望你能有所收獲。
分享文章:MySQL數(shù)據(jù)庫(kù)的基本知識(shí)大全
網(wǎng)頁(yè)鏈接:http://www.fisionsoft.com.cn/article/cddpcps.html


咨詢
建站咨詢
