MySQL5.7: sql script demo

来源:https://www.cnblogs.com/geovindu/archive/2018/09/19/9675372.html
-Advertisement-
Play Games

/* CREATE DATABASE geovindu DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; use geovindu; */ -- 查詢編碼格式 show variables like '%char%'; -- SE... ...


 

 

/*
CREATE DATABASE geovindu
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_general_ci;

use geovindu;

*/
-- 查詢編碼格式
show variables like '%char%';

-- SET NAMES GB2312; 

ALTER DATABASE  geovindu
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_general_ci;

-- 修改數據的編碼格式
ALTER DATABASE geovindu
    DEFAULT CHARACTER SET utf8
   -- default character set=utf8
   -- default character set server=utf8
   -- default collation server=utf8_general_ci
    DEFAULT COLLATE utf8_general_ci;
    
 -- 設置   
SET character_set_server = utf8;

set character_set_results=gb2312; 

SET character_set_database = latin1;

select 'host' from user; -- where user='root';

/*
szcentilc.com 

'character_set_client', 'utf8'
'character_set_connection', 'utf8'
'character_set_database', 'latin1'
'character_set_filesystem', 'binary'
'character_set_results', 'utf8'
'character_set_server', 'latin1'
'character_set_system', 'utf8'


20180709
character_set_client utf8 
character_set_connection utf8 
character_set_database utf8 
character_set_filesystem binary 
character_set_results utf8 
character_set_server latin1 
character_set_system utf8 

*/
 /*
 原始的
 character_set_client	utf8
character_set_connection	utf8
character_set_database	latin1  -- phpmyadmin2 客戶查詢亂碼
character_set_filesystem	binary
character_set_results	utf8
character_set_server	latin1
character_set_system	utf8

mysql> SET character_set_client = utf8 ;
mysql> SET character_set_connection = utf8 ;
mysql> SET character_set_database = utf8 ;
mysql> SET character_set_results = utf8 ;
mysql> SET character_set_server = utf8 ;
 
mysql> SET collation_connection = utf8 ;
mysql> SET collation_database = utf8 ;
mysql> SET collation_server = utf8 ; 
 */  
 
SHOW DATABASES;
SHOW DATABASES; -- 列出 MySQL Server 上的資料庫。
SHOW TABLES FROM test; -- 列出資料庫的資料表。
SHOW TABLE STATUS FROM test; -- 列出資料庫的資料表,提供比較詳細的訊息。
SHOW COLUMNS FROM test; -- 列出資料表的欄位,同 SHOW FIELDS FROM tbl_name [FROM db_name],DESCRIBE tbl_name [col_name]。
SHOW FULL COLUMNS FROM test; -- 列出資料表的欄位,提供比較詳細的訊息,同 SHOW FULL FIELDS FROM tbl_name [FROM db_name]。
SHOW INDEX FROM test; -- 列出資料表的索引訊息。
SHOW STATUS; -- 列出 Server 的狀態訊息。
SHOW VARIABLES; -- 列出 MySQL 系統變數的值。
SHOW PROCESSLIST; -- 顯示哪個執行緒正在運行。
SHOW GRANTS FOR user; -- 列出對一個用戶必須發出以重複授權的授權命令

-- 主鍵
select * from information_schema.KEY_COLUMN_USAGE;

-- https://dev.mysql.com/doc/refman/8.0/en/keywords-table.html
select * from information_schema.KEYWORDS;

SELECT * FROM INFORMATION_SCHEMA.KEYWORDS;

select
    concat(table_name, '.', column_name) as 'foreign key',  
    concat(referenced_table_name, '.', referenced_column_name) as 'references'
from
    information_schema.key_column_usage
where
    referenced_table_name is not null;


drop table  IF EXISTS  BookKindList;
create table BookKindList
(
	BookKindID INT NOT NULL AUTO_INCREMENT  comment '自動增長ID',
	BookKindName nvarchar(500) not null comment '書類名',
	BookKindParent int null comment '父節點',
   PRIMARY KEY(BookKindID)  #主鍵
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='書類表' AUTO_INCREMENT=1;


#更新 
DELIMITER $$
DROP PROCEDURE IF EXISTS `geovindu`.`proc_Update_BookKindList` $$
CREATE PROCEDURE `geovindu`.`proc_Update_BookKindList` (IN param1ID Int,IN param1Name NVarChar(1000),IN param1Parent Int)
BEGIN
IF NOT EXISTS (SELECT * FROM BookKindList WHERE BookKindName=param1Name) then
UPDATE BookKindList
	SET
		BookKindName=param1Name ,
		BookKindParent=param1Parent
	where
		BookKindID=param1ID;
ELSE
    UPDATE BookKindList
	SET BookKindParent=param1Parent
	where
		BookKindID=param1ID;
END IF;
END $$

#IN 表示輸入參數
#OUT表示輸出參數
#INOUT:表示即可以輸入參數也可以輸出參數
#存儲過程 利用mysql-query-browser創建存儲過程和函數

#刪除
DELIMITER $$
DROP PROCEDURE IF EXISTS `geovindu`.`DeleteBookKind` $$
CREATE PROCEDURE `geovindu`.`DeleteBookKind` (IN param1 INT)
BEGIN
         Delete From bookkindlist WHERE BookKindID  = param1;
END $$
DELIMITER ;

#查詢所有
DELIMITER $$
DROP PROCEDURE IF EXISTS `geovindu`.`proc_Select_BookKindListAll` $$
CREATE PROCEDURE `geovindu`.`proc_Select_BookKindListAll` ()
BEGIN
    SELECT * FROM bookkindlist;
END $$
DELIMITER ;


select * from  `geovindu`.`bookkindlist`;
SELECT * FROM bookkindlist;

#統計
DELIMITER $$
DROP PROCEDURE IF EXISTS `geovindu`.`BookKindCount` $$
CREATE PROCEDURE `geovindu`.`BookKindCount` (OUT param1ID INT)
BEGIN
        select COUNT(*) into param1ID  From bookkindlist;
END $$
DELIMITER ;
#查詢一條
DELIMITER $$
DROP PROCEDURE IF EXISTS `geovindu`.`proc_Select_BookKindList` $$
CREATE PROCEDURE `geovindu`.`proc_Select_BookKindList` (IN param1 INT)
BEGIN
        SELECT * FROM BookKindList WHERE BookKindID = param1;
END $$
DELIMITER ;

#插入一條
DELIMITER $$
DROP PROCEDURE IF EXISTS `geovindu`.`proc_Insert_BookKindList` $$
CREATE PROCEDURE `geovindu`.`proc_Insert_BookKindList` (IN param1Name NVarChar(1000),IN param1Parent Int)
BEGIN
        insert into BookKindList(BookKindName,BookKindParent) values(param1Name,param1Parent);
END $$
DELIMITER ;

#插入一條返回值
DELIMITER $$

DROP PROCEDURE IF EXISTS `geovindu`.`proc_Insert_BookKindOut` $$
CREATE PROCEDURE `geovindu`.`proc_Insert_BookKindOut` (IN param1Name NVarChar(1000),IN param1Parent Int,OUT ID INT)
BEGIN
     IF NOT EXISTS (SELECT * FROM BookKindList WHERE BookKindName=param1Name) then
        INSERT INTO BookKindList (BookKindName,BookKindParent)VALUES(param1Name ,param1Parent);
        #set ID=Last_insert_id()
        SELECT LAST_INSERT_ID() into ID;
      end if;
END $$

DELIMITER ;


/*自定義函數*/
#部門函數
DELIMITER $$
DROP FUNCTION IF EXISTS `geovindu`.`f_GetDepartmentName` $$
CREATE FUNCTION `geovindu`.`f_GetDepartmentName` (did int) RETURNS varchar(100)
BEGIN
declare str varchar(100);
return(select DepartmentName from DepartmentList where DepartmentID=did);
END $$
DELIMITER ;

#使用函數
select f_GetDepartmentName(1);

select * from BookInfoList;
#作家函數

DELIMITER $$
DROP FUNCTION IF EXISTS `geovindu`.`f_GetBookKindName` $$
CREATE FUNCTION `geovindu`.`f_GetBookKindName` (did int) RETURNS varchar(400)
BEGIN
   declare str varchar(100);
return(select BookKindName from BookKindList where BookKindID=did);
END $$
DELIMITER ;


-- 用戶瀏覽記錄
drop table  IF EXISTS  DuwebStat;
CREATE TABLE IF NOT EXISTS `DuwebStat` (
    `id` int(11) NOT NULL auto_increment  comment '自動增長ID',
    `seepage` varchar(200)  character set utf8 null comment '瀏覽的網頁',
    `userip` varchar(100)  character set utf8 null comment '登錄IP',
    `OSer` varchar(200)  character set utf8 null comment '操作系統',
    `Operating` varchar(100)  character set utf8 null comment '操作系統',
    `Browser` varchar(500)  character set utf8 null comment '瀏覽器',
    `Visioner` varchar(100)  character set utf8 null comment '版本',
    `Languageer` varchar(100)  character set utf8 null comment '語言版本',
    `IsCookie` varchar(100)  character set utf8 null comment '是否有Cookie',
    `BSize` varchar(100)  character set utf8 null comment '瀏覽器尺寸',
    `DetectedOpertor` text  character set utf8 null comment '客戶端環境描述',
    `Addtime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '添加時間',
  PRIMARY KEY  (`id`)
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='用戶瀏覽記錄表' AUTO_INCREMENT=1;

-- 考慮主鍵外鍵
-- 
drop table  IF EXISTS  EnterpriseType;
-- 2  企業類型表
create table EnterpriseType
(
   EnterpriseTypeID int(20) NOT NULL auto_increment  comment '自動增長ID',
   EnterpriseTypeName nvarchar(100) not null comment '企業類型名稱',					-- 企業類型名稱
   PRIMARY KEY  (EnterpriseTypeID)
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='企業類型表' AUTO_INCREMENT=1;

insert into EnterpriseType (EnterpriseTypeName) values(N'分公司');
insert into EnterpriseType (EnterpriseTypeName) values(N'店鋪');

select * from OperatingUser;
-- 3 公司表
drop table CompanyBranch;

create table CompanyBranch
(
    CompanyID int(20) NOT NULL auto_increment  comment '自動增長ID',
    CompanyName nvarchar(100) not null  comment '公司名稱',
    CompanyTypeID int not null  comment '企業類型ID',
    CompanyDate  timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '添加時間',
    CompanyDesc NVARCHAR(500) null  comment '公司描述',
    CompanyTel varchar(100) null  comment '公司電話',
    CompanyFax VARCHAR(100) NULL  comment '公司傳真',
    CompanyAddress NVARCHAR(500) NULL  comment '公司地址',
    PRIMARY KEY  (CompanyID),
    FOREIGN KEY(CompanyTypeID) REFERENCES EnterpriseType(EnterpriseTypeID)
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='公司表' AUTO_INCREMENT=1;


insert into CompanyBranch(CompanyName,CompanyTypeID,CompanyTel,CompanyFax,CompanyAddress,CompanyDesc) values('六福珠寶營銷策劃(深圳)有限公司',1,'','','','');

select * from CompanyBranch;

select * from EnterpriseType;

drop table OperatingUser;
-- 1 
create table OperatingUser
(
	UserID  int(20) PRIMARY KEY  NOT NULL auto_increment  comment '自動增長ID',
    UserName nvarchar(200) not null comment '用戶名',						-- 用戶名
	RealName NVARCHAR(50) NOT NULL comment '真實姓名',						-- 真姓名
	UserPassword varchar(100) not null comment '密碼',					-- 密碼
	UserCompanyId int not null comment '公司ID',						-- 公司ID
	UserPasswordProblems nvarchar(100) comment '找回密碼問題',					-- 找回密碼問題	
	UserMail varchar(100) null comment '郵件',						-- 郵件
	UserDate timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '添加時間',                                    -- 預設日期
	FOREIGN KEY(UserCompanyId) REFERENCES CompanyBranch(CompanyID)

)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='用戶表' AUTO_INCREMENT=1;

select * from OperatingUser;


-- 4 登錄日誌表
drop table LoginDiaryList;
drop table  IF EXISTS  LoginDiaryList;
CREATE TABLE LoginDiaryList
(
	LoginDiaryID int(20)  PRIMARY KEY  NOT NULL auto_increment  comment '自動增長ID',
	LoginDiaryUserName nvarchar(50) null comment '登錄用戶名',		-- 登錄用戶名	
	LoginDiaryUserId int not null comment '員工ID', 			-- 員工ID
	LoginDiaryBrowser varchar(50) null comment '客戶端瀏覽',		-- 客戶端瀏覽
	LoginDiaryScreen varchar(50) null comment '顯示器大小',			-- 顯示器大小
	LoginDiaryOpertor varchar(50) null comment '操作系統',		-- 操作系統
	LoginDiaryInput nvarchar(150) null comment '輸入法',		-- 輸入法
	LoginDiaryDate   timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '添加時間', 	-- 日期
    FOREIGN KEY(LoginDiaryUserId) REFERENCES OperatingUser(UserID)
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='登錄日誌表' AUTO_INCREMENT=1;


select * from LoginDiaryList;

select * from PrintWordDocumentTemplateList;

-- 5
drop table  IF EXISTS  PrintWordDocumentTemplateList;
create table PrintWordDocumentTemplateList
(
	PrintWordDocumentId int PRIMARY KEY auto_increment  comment '自動增長ID',
	-- PrintWordDocumentUid Uniqueidentifier DEFAULT(NEWID())  PRIMARY KEY,	
	-- PrintWordPayTypeUidKey Uniqueidentifier,				-- 考核類型(試用期,年終,特別)
	-- PrintWordJobTypeUidKey Uniqueidentifier,				-- -職位類型(文職類,員工類,管理級別類等)
	PrintWordOnlyPassIs bit(1) default b'0' comment '通過試用期並成為正式員工',				-- -通過試用期並成為正式員工
	PrintWordPlusSalaryIs bit default b'0' comment '通過並加薪',				-- -通過並加薪
	PrintWordPromotionIs bit default b'0' comment '通過晉升',				-- -通過晉升
	PrintWordExtensionIs bit default b'0'  comment '延長試用期',				-- 延長試用期
	PrintWordDismissIs bit default b'0' comment '解僱',					-- 解僱
	PrintWordDepartmentIs bit default b'0' comment '新部門',				-- 新部門
	PrintWordDocumentName Nvarchar(100) not null comment '文檔標題',				-- 文檔標題
	PrintWordDocumentUrl nvarchar(200) null comment '文檔鏈接',				-- 文檔鏈接
	PrintWordDocumentContent nvarchar(300) null comment '文檔簡要描述',				-- 文檔簡要描述
	PrintWordDocumentAddDate   timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '添加時間', 
	PrintWordDocumentByte BLOB null comment '文檔',
	PrintWordType int(20) default 1 comment '文檔類型' 				-- 文檔類型 1.分公司,2.分店
	-- PrintWordLetterSignature nvarchar(100) null				-- 信函簽名

)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='列印單表' AUTO_INCREMENT=1;


-- 6 
-- 客戶表Customer(需方) 名稱,工地名稱
drop table CustomerList;

drop table  IF EXISTS  CustomerList;
CREATE TABLE CustomerList
(
	CustomerID int(20) PRIMARY KEY auto_increment  comment '自動增長ID',
	CustomerName NVARCHAR(200) NOT NULL comment '客戶姓名',
	CustomerNamePin VARCHAR(500) NULL comment '拼音首字母',
	CustomerContact NVARCHAR(50) NULL comment '聯系人',			-- 聯系人
	CustomerTel VARCHAR(100) NULL comment '聯系人電話',			-- 聯系人電話
	CustomerDate timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '添加時間' 
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='客戶表' AUTO_INCREMENT=1;


-- 7表單關聯人類型RelationshipsType: 指定收貨人 跟單業務員 工地驗收人 運輸人
drop table RelationshipsType;
drop table  IF EXISTS  RelationshipsType;

CREATE TABLE RelationshipsType
(
	RelationshipsTypeID int(20) PRIMARY KEY auto_increment  comment '自動增長ID',
	RelationshipsTypeName NVARCHAR(100) NOT NULL comment '關係類型名稱',
	RelationshipsTypePin VARCHAR(500) NULL comment '拼音首字母'
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='表單關聯人類型表' AUTO_INCREMENT=1;

insert into RelationshipsType(RelationshipsTypeName) values('指定收貨人');
insert into RelationshipsType(RelationshipsTypeName) values('跟單業務員');
insert into RelationshipsType(RelationshipsTypeName) values('工地驗收人');
insert into RelationshipsType(RelationshipsTypeName) values('運輸人');

-- 8表單關係人錶RelationshipsPerson  
drop table RelationshipsPerson;
drop table  IF EXISTS  RelationshipsPerson;
CREATE TABLE RelationshipsPerson
(
	PersonID int(20) PRIMARY KEY  auto_increment  comment '自動增長ID',
	PersonName NVARCHAR(100) NOT NULL comment '姓名',
	PersonNamePin VARCHAR(500) NULL comment '拼音首字母',
	PersonTel VARCHAR(100) comment '電話',
	PersonType int NOT NULL comment '類型',
	PersonDate timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '添加時間',
	FOREIGN KEY(PersonType) REFERENCES RelationshipsType(RelationshipsTypeID)
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='表單關係人' AUTO_INCREMENT=1;

select * from RelationshipsPerson;



-- 9產品名稱表 ProductTypeList
drop table ProductTypeList;

drop table  IF EXISTS  ProductTypeList;
CREATE TABLE ProductTypeList
(
	ProductTypeID INTEGER PRIMARY KEY auto_increment  comment '自動增長ID',
	ProductTypeName NVARCHAR(800) NOT NULL comment '產品名稱',
	ProductTypePin VARCHAR(500) NULL comment '拼音首字母'     -- 字首字母
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='產品名稱表' AUTO_INCREMENT=1;

-- 10單位表 UnitList   comment ''
drop table UnitList;

drop table  IF EXISTS  UnitList;

CREATE TABLE UnitList
(
	UnitID INTEGER PRIMARY KEY auto_increment  comment '自動增長ID',
	UnitName NVARCHAR(100) NOT NULL comment '單位名稱',
	UnitPin VARCHAR(500) NULL comment '拼音首字母'
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='單位表' AUTO_INCREMENT=1;

select * from UnitList;

delete from UnitList where UnitName='';

drop table ProductModel;
-- 產品規格
drop table  IF EXISTS  ProductModel;

CREATE TABLE ProductModel
(
	ModelID INTEGER PRIMARY KEY auto_increment  comment '自動增長ID',
	ModelProductTypeID INT NOT NULL comment '產品名稱ID',        -- 產品名稱ID 外鍵 ProductTypeList
	ModelName NVARCHAR(800) NOT NULL comment '產品規格',
	ModelPin VARCHAR(500) NULL comment '拼音首字母',  
    KEY ModelProductTypeID (ModelProductTypeID),
	CONSTRAINT ProductModel_ibfk_1 FOREIGN KEY(ModelProductTypeID) REFERENCES ProductTypeList(ProductTypeID)
    ON UPDATE CASCADE
   ON DELETE RESTRICT
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='產品規格表' AUTO_INCREMENT=1;


--  MyISAM Foreign Keys顯示不了外鍵
drop table  IF EXISTS  city;
CREATE TABLE `city` (
  `ID` int(11) NOT NULL AUTO_INCREMENT comment'',
  `Name` char(35) NOT NULL DEFAULT '' comment'',
  `CountryCode` char(3) NOT NULL DEFAULT '' comment'',
  `District` char(20) NOT NULL DEFAULT '' comment'',
  `Population` int(11) NOT NULL DEFAULT '0' comment'',
  PRIMARY KEY (`ID`),
  KEY `CountryCode` (`CountryCode`),
  CONSTRAINT `city_ibfk_1` FOREIGN KEY (`CountryCode`) REFERENCES `country` (`Code`)
) ENGINE=MyISAM COMMENT='城市表' AUTO_INCREMENT=4080 DEFAULT CHARSET=utf8;

drop table  IF EXISTS  country;
CREATE TABLE `country` (
  `Code` char(3) NOT NULL DEFAULT ''  comment'',
  `Name` char(52) NOT NULL DEFAULT '' comment'',
  `Continent` enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia' comment'',
  `Region` char(26) NOT NULL DEFAULT '' comment'',
  `SurfaceArea` float(10,2) NOT NULL DEFAULT '0.00' comment'',
  `IndepYear` smallint(6) DEFAULT NULL comment'',
  `Population` int(11) NOT NULL DEFAULT '0' comment'',
  `LifeExpectancy` float(3,1) DEFAULT NULL comment'',
  `GNP` float(10,2) DEFAULT NULL comment'',
  `GNPOld` float(10,2) DEFAULT NULL comment'',
  `LocalName` char(45) NOT NULL DEFAULT '' comment'',
  `GovernmentForm` char(45) NOT NULL DEFAULT '' comment'',
  `HeadOfState` char(60) DEFAULT NULL comment'',
  `Capital` int(11) DEFAULT NULL comment'',
  `Code2` char(2) NOT NULL DEFAULT '' comment'',
  PRIMARY KEY (`Code`)
) ENGINE=MyISAM COMMENT='國家表' DEFAULT CHARSET=utf8;



--  InnoDB  Foreign Keys顯示外鍵

drop table  IF EXISTS  city;
CREATE TABLE `city` (
  `ID` int(11) NOT NULL AUTO_INCREMENT comment'',
  `Name` char(35) NOT NULL DEFAULT '' comment'',
  `CountryCode` char(3) NOT NULL DEFAULT '' comment'',
  `District` char(20) NOT NULL DEFAULT '' comment'',
  `Population` int(11) NOT NULL DEFAULT '0' comment'',
  PRIMARY KEY (`ID`),
  KEY `CountryCode` (`CountryCode`),
  CONSTRAINT `city_ibfk_1` FOREIGN KEY (`CountryCode`) REFERENCES `country` (`Code`)
) ENGINE=InnoDB COMMENT='城市表' AUTO_INCREMENT=4080 DEFAULT CHARSET=utf8;




drop table  IF EXISTS  country;
CREATE TABLE `country` (
  `Code` char(3) NOT NULL DEFAULT ''  comment'',
  `Name` char(52) NOT NULL DEFAULT '' comment'',
  `Continent` enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia' comment'',
  `Region` char(26) NOT NULL DEFAULT '' comment'',
  `SurfaceArea` float(10,2) NOT NULL DEFAULT '0.00' comment'',
  `IndepYear` smallint(6) DEFAULT NULL comment'',
  `Population` int(11) NOT NULL DEFAULT '0' comment'',
  `LifeExpectancy` float(3,1) DEFAULT NULL comment'',
  `GNP` float(10,2) DEFAULT NULL comment'',
  `GNPOld` float(10,2) DEFAULT NULL comment'',
  `LocalName` char(45) NOT NULL DEFAULT '' comment'',
  `GovernmentForm` char(45) NOT NULL DEFAULT '' comment'',
  `HeadOfState` char(60) DEFAULT NULL comment'',
  `Capital` int(11) DEFAULT NULL comment'',
  `Code2` char(2) NOT NULL DEFAULT '' comment'',
  PRIMARY KEY (`Code`)
) ENGINE=InnoDB COMMENT='國家表' DEFAULT CHARSET=utf8;



drop table UnitPrice;

-- 單價表
drop table  IF EXISTS  UnitPrice;
CREATE TABLE UnitPrice
(
	UnitPriceID INTEGER PRIMARY KEY auto_increment  comment '自動增長ID',
	UnitProductTypeID INT NOT NULL comment '產品名稱ID',        -- 產品名稱ID 外鍵 ProductTypeList
	UnitPriceNuber DECIMAL(20,2) NOT NULL comment '單價',
	UnitPricePin VARCHAR(500) NULL comment '拼音首字母',
	FOREIGN KEY(UnitProductTypeID) REFERENCES ProductTypeList(ProductTypeID)
        ON UPDATE CASCADE
   ON DELETE RESTRICT
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='單價表' AUTO_INCREMENT=1;

select * from UnitPrice;

drop table CustomerAddress;
--  客戶地址表 
drop table  IF EXISTS  CustomerAddress;
CREATE TABLE CustomerAddress
(
	AddressID INTEGER PRIMARY KEY auto_increment  comment '自動增長ID',
	AddressName NVARCHAR(100) NOT NULL comment '地名',
	AddressPin VARCHAR(500) NULL comment '拼音首字母'
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='客戶地址表' AUTO_INCREMENT=1;


-- 11級別表 LevelList
drop table LevelList;
drop table  IF EXISTS  LevelList;
CREATE TABLE LevelList
(
	LevelID INTEGER PRIMARY KEY auto_increment  comment '自動增長ID',
	LevelName NVARCHAR(100) NOT NULL comment '級別名稱',
	LevelPin VARCHAR(500) NULL comment '拼音首字母'
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='級別表' AUTO_INCREMENT=1;

select * from LevelList;

delete from LevelList where LevelName='';


-- 12工地名名稱表 建築工地名Construction site name
drop table ConstructionNameList;

drop table  IF EXISTS  ConstructionNameList;
CREATE TABLE ConstructionNameList
(
	ConstructionID INTEGER PRIMARY KEY auto_increment  comment '自動增長ID',
	ConstructionName VARCHAR(100) NOT NULL comment '工地名稱',
	ConstructionPin VARCHAR(500) NULL comment '拼音首字母'
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='工地名名稱表' AUTO_INCREMENT=1;

select * from ConstructionNameList;

delete from ConstructionNameList where ConstructionName='';

-- 訂單產品詳情表
drop table OrderItDetails;
drop table  IF EXISTS  OrderItDetails;
CREATE TABLE OrderItDetails
(
	OrderID INTEGER PRIMARY KEY auto_increment  comment '自動增長ID',
	OrderDate timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '送貨日期',	 	-- 送貨日期
	OrderWord VARCHAR(50) NULL comment '字',				-- 字
	OrderNo VARCHAR(100) NULL comment '號',				-- 號
	OrderCustomerId INT NOT NULL comment '客戶名稱',				-- 客戶名稱
	OrderAddressID INT NOT NULL comment '客戶地址名稱',				-- 客戶地址名稱		
	OrderPrepared INT NULL comment '製單人',				-- 製單人
	OrderBusiness INT NULL comment '指定收貨人',				-- 指定收貨人											
	OrderPrintDate timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '打單時間',	-- 打單時間
	FOREIGN KEY(OrderCustomerId) REFERENCES CustomerList(CustomerID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT,
	FOREIGN KEY(OrderAddressID) REFERENCES CustomerAddress(AddressID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT,
	FOREIGN KEY(OrderPrepared) REFERENCES RelationshipsPerson(PersonID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT,
	FOREIGN KEY(OrderBusiness) REFERENCES RelationshipsPerson(PersonID)
    ON UPDATE CASCADE
   ON DELETE RESTRICT
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='訂單產品詳情表' AUTO_INCREMENT=1;

-- 訂單產品詳情
drop table ProductItOrderDetails;
drop table  IF EXISTS  ProductItOrderDetails;
CREATE TABLE ProductItOrderDetails
(
    ProductDetailsId INTEGER PRIMARY KEY auto_increment  comment '自動增長ID',
    ProductOrderId INT NOT NULL comment '產品訂單ID',			-- 產品訂單ID  外錶OrderDetails
	ProductOrderTypeId INT NOT NULL comment '產品名稱ID',			-- 產品名稱
	ProductModleId INT comment '規格ID',	  			-- 規格
	ProductUnitID INT comment '單位ID',				-- 單位
	ProductQty DECIMAL(18,2) DEFAULT 0 comment '數量',		-- 數量
	ProductPriceID INT NOT NULL comment '單價ID',			-- 單價
	ProductMeters DECIMAL(25,2) DEFAULT 0 comment '金額',		-- 金額
	ProductDescription VARCHAR(1000) NULL comment '說明',		-- 說明
	FOREIGN KEY(ProductOrderId) REFERENCES OrderItDetails(OrderID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT,
	FOREIGN KEY(ProductOrderTypeId) REFERENCES ProductTypeList(ProductTypeID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT,
	FOREIGN KEY(ProductModleId) REFERENCES ProductModel(ModelID)
    ON UPDATE CASCADE
	ON DELETE RESTRICT,
	FOREIGN KEY(ProductUnitID) REFERENCES UnitList(UnitID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT,
	FOREIGN KEY(ProductPriceID) REFERENCES UnitPrice(UnitPriceID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='訂單產品詳情表' AUTO_INCREMENT=1;


-- 13打單表內容 ProductDetails
-- https://www.sqlite.org/datatype3.html
drop table OrderDetails;
drop table  IF EXISTS  OrderDetails;
CREATE TABLE OrderDetails
(
	OrderID INTEGER PRIMARY KEY auto_increment  comment '自動增長ID',
	OrderDate timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '添加時間',		-- 日期
	OrderWord NVARCHAR(50) NULL comment '字',				-- 字
	OrderNo NVARCHAR(100) NULL comment '號',				-- 號
	OrderCustomerId int NOT NULL comment '需求方ID',				-- 需求方
	OrderConstructionId int NOT NULL comment '工地名稱ID',				-- 工地名稱   
    	-- OrderProductId int NOT NULL,				-- 產品訂單詳情ID  外錶ProductOrderDetails
	OrderAcceptor int NULL comment '工地驗收人ID',				-- 工地驗收人
	OrderTransportation	 INTEGER NULL comment '運輸人ID',			-- 運輸人
	OrderPrepared int NULL comment '製單人ID',				-- 製單人
	OrderBusiness int NULL comment '指定業務人ID',				-- 指定業務人
	OrderMerchandiser int NULL comment '跟單業務員ID',				-- 跟單業務員											
	OrderPrintDate timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '打單時間',-- 打單時間
	FOREIGN KEY(OrderCustomerId) REFERENCES CustomerList(CustomerID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT,
	FOREIGN KEY(OrderConstructionId) REFERENCES ConstructionNameList(ConstructionID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT,	
    FOREIGN KEY(OrderAcceptor) REFERENCES RelationshipsPerson(PersonID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT,
    FOREIGN KEY(OrderTransportation) REFERENCES RelationshipsPerson(PersonID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT,
	FOREIGN KEY(OrderPrepared) REFERENCES RelationshipsPerson(PersonID)
    ON UPDATE CASCADE
	ON DELETE RESTRICT,
	FOREIGN KEY(OrderBusiness) REFERENCES RelationshipsPerson(PersonID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT,
	FOREIGN KEY(OrderMerchandiser) REFERENCES RelationshipsPerson(PersonID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT	
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='打單表內容表' AUTO_INCREMENT=1;

-- 14訂單產品詳情表 NUMERIC 
drop table ProductOrderDetails;
drop table  IF EXISTS  ProductOrderDetails;
CREATE TABLE ProductOrderDetails
(
    ProductDetailsId int PRIMARY KEY auto_increment  comment '自動增長ID',
	ProductOrderId INT NOT NULL comment '產品訂單ID',				-- 產品訂單ID  外錶OrderDetails
	ProductTypeId int NOT NULL comment '產品名稱規格ID',				-- 產品名稱規格
	ProductUnitID int NOT NULL comment '單位ID',				-- 單位
	ProductQty DECIMAL(18,2) DEFAULT 0.0 comment '數量',			-- 數量
	ProductLevelID int NOT NULL comment '級別ID',				-- 級別
	ProductMeters DECIMAL(25,2) DEFAULT 0 comment '米數',			-- 米數
	ProductDescription NVARCHAR(1000) NULL comment '說明',			-- 說明
	FOREIGN KEY(ProductOrderId) REFERENCES OrderDetails(OrderID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT,
	FOREIGN KEY(ProductTypeId) REFERENCES ProductTypeList(ProductTypeID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT,
	FOREIGN KEY(ProductUnitID) REFERENCES UnitList(UnitID)
    ON UPDATE CASCADE
    ON DELETE RESTRICT,
	FOREIGN KEY(ProductLevelID) REFERENCES LevelList(LevelID)	
    ON UPDATE CASCADE
    ON DELETE RESTRICT	
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='訂單產品詳情表' AUTO_INCREMENT=1;



-- 設置移動列印X,Y坐標糾正值
drop table PrintSetNumber;
drop table  IF EXISTS  PrintSetNumber;
CREATE TABLE PrintSetNumber
(
	PrintSetId int PRIMARY KEY auto_increment  comment '自動增長ID',
	PrintSetX int unsigned default 0 comment '列坐標',  -- com 列坐標
	PrintSetY int default 0 comment '行坐標', -- row 行坐標
	PrintPrinter VARCHAR(200) NULL comment '預設印表機名',	-- 預設印表機名
	PrintFont VARCHAR(200) NULL default '宋體' comment '預設字體名',--  預設字體名
    PrintBottom bit default 0 comment '底部文字是否雙排',	-- 底部文字是否雙排 
	TitleFontSize int default 8 comment '標題字體大小',     -- 標題字體大小
	ConFontSize int default 8 comment '內容字體大小',	-- 內容字體大小
	HeadFontSize int default 8 comment '表頭字體大小',	-- 表頭字體大小
	BoomFontSize int default 8 comment '表底字體大小'	-- 表底字體大小
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='設置移動列印' AUTO_INCREMENT=1;

-- 表的描述
drop table DataTableDesc;
drop table  IF EXISTS  DataTableDesc;
CREATE TABLE DataTableDesc
(
	TableId int PRIMARY KEY auto_increment  comment '自動增長ID',
	TableName nvarchar(100) not null comment '表名',
	TableDesc nvarchar(100) null comment '表描述'
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='表的描述' AUTO_INCREMENT=1;


-- 列的列描述 columnName
drop table DataColumnDesc;
drop table  IF EXISTS  DataColumnDesc;
CREATE TABLE DataColumnDesc
(
	ColumnId int PRIMARY KEY auto_increment  comment '自動增長ID',
	ColumnTableId int not null comment '表ID',
	ColumnName nvarchar(100) not null comment '列名',
	ColumnDesc nvarchar(100) null comment '列描述',
    -- KEY ColumnTableId (ColumnTableId),  --此項添上也可以
    -- CONSTRAINT `DataColumnDesc_ibfk_1`  --此項添上也可以 
	FOREIGN KEY(ColumnTableId) REFERENCES DataTableDesc(TableId)
)ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='列的列描述' AUTO_INCREMENT=1;

select * from DataTableDesc;

select * from DataColumnDesc;


select * from PrintSetNumber;

-- 視圖
CREATE VIEW v_DataTableColumn as 
select DataColumnDesc.*,DataTableDesc.TableName,DataTableDesc.TableDesc from DataColumnDesc,DataTableDesc 
where DataTableDesc.TableId=DataColumnDesc.ColumnTableId;

CREATE VIEW v_OperatingUser as 
select OperatingUser.*,CompanyBranch.CompanyName,CompanyBranch.companyTel,CompanyBranch.CompanyFax,CompanyBranch.CompanyAddress
 from OperatingUser,CompanyBranch where OperatingUser.UserCompanyId=CompanyBranch.CompanyID;


drop view v_CompanyBranch;
-- 公司
create view v_CompanyBranch
as
select CompanyBranch.*,EnterpriseType.EnterpriseTypeName from CompanyBranch, EnterpriseType where CompanyBranch.CompanyTypeID=EnterpriseType.EnterpriseTypeID;


select CompanyBranch.*,EnterpriseType.EnterpriseTypeName from CompanyBranch, EnterpriseType where CompanyBranch.CompanyTypeID=EnterpriseType.EnterpriseTypeID;

select * from v_CompanyBranch;


drop view v_OperatingUser;
-- 用戶
create view v_OperatingUser
as
select OperatingUser.*,CompanyBranch.CompanyName,CompanyBranch.companyTel,CompanyBranch.CompanyFax,CompanyBranch.CompanyAddress from OperatingUser,CompanyBranch  where OperatingUser.UserCompanyId=CompanyBranch.CompanyID;

select * from v_OperatingUser;

-- 錶單用戶視圖

CREATE VIEW view_relationshipsPerson
AS
select RelationshipsPerson.*,RelationshipsType.RelationshipsTypeName FROM RelationshipsPerson,RelationshipsType
WHERE RelationshipsPerson.PersonType=RelationshipsType.RelationshipsTypeID;


-- 訂單視圖

  

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using MySql.Data;
using MySql.Data.MySqlClient;
/*
 * 
 MetaDataCollections
DataSourceInformation
DataTypes
Restrictions
ReservedWords
Databases
Tables
Columns
Users
Foreign Keys
IndexColumns
Indexes
Foreign Key Columns
UDF
Views
ViewColumns
Procedure Parameters
Procedures
Triggers
 
 */


namespace MySqlDemo
{

    /// <summary>
    /// 
    /// </summary>
    public partial class Form2 : Form
    {

        /// <summary>
        /// 都可以用
        /// </summary>
        private static string connectionString = @"Database='geovindu';Data Source='localhost';User Id='root';Password='88888';charset='utf8';pooling=true;Port=3306;Allow Zero Datetime=true;";
        /// <summary>
        /// 都可以用
        /// </summary>
        private static string connectionString1 = @"Database='geovindu';server='localhost';User Id='root';Password='88888';charset='utf8';pooling=true;Port=3306;Allow Zero Datetime=true;";

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        private DataTable setTables()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("id", typeof(int));
            dt.Columns.Add("name", typeof(string));
            dt.Rows.Add(1, "MetaDataCollections");//MetaData集合
            dt.Rows.Add(2, "DatasourceInformation");//資料庫文件版本等信息
            dt.Rows.Add(3, "DataTypes");//欄位類型
            dt.Rows.Add(4, "Restrictions");//架構限制
            dt.Rows.Add(5, "ReservedWords");//限制關鍵字
            dt.Rows.Add(6, "Databases");//資料庫(包含系統資料庫)
            dt.Rows.Add(7, "Tables");//所有表包括系統表
            dt.Rows.Add(8, "Columns");//表的欄位
            dt.Rows.Add(9, "Users");//用戶
            dt.Rows.Add(10, "Foreign Keys");//外鍵表和主表 (不包含列)
            dt.Rows.Add(11, "IndexColumns");//有鍵的表及主鍵
            dt.Rows.Add(12, "Indexes");//所有有主鍵的表
            dt.Rows.Add(13, "Foreign Key Columns");// 外鍵表和主表及列
            dt.Rows.Add(14, "UDF");//
            dt.Rows.Add(15, "Views");//所有視圖
            dt.Rows.Add(16, "ViewColumns");//視圖的欄位
            dt.Rows.Add(17, "Procedure Parameters");//存儲過程參數
            dt.Rows.Add(18, "Procedures");//存儲過程
            dt.Rows.Add(19, "Triggers");   
            return dt;
        }
        /// <summary>
        /// 
        /// </summary>
        MySqlConnection connection = new MySqlConnection(connectionString1);
        /// <summary>
        /// open connection to database
        /// </summary>
        /// <returns></returns>
        private bool OpenConnection()
        {
            try
            {
                connection.Open();
                return true;
            }
            catch (MySqlException ex)
            {
                //When handling errors, you can your application's response based 
                //on the error number.
                //The two most common error numbers when connecting are as follows:
                //0: Cannot connect to server.
                //1045: Invalid user name and/or password.
                switch (ex.Number)
                {
                    case 0:
                        MessageBox.Show("Cannot connect to server.  Contact administrator");
                        break;

                    case 1045:
                        MessageBox.Show("Invalid username/password, please try again");
                        break;
                }
                return false;
            }
        }

        /// <summary>
        /// Close connection
        /// </summary>
        /// <returns></returns>
        private bool CloseConnection()
        {
            try
            {
                connection.Close();
                return true;
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public Form2()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form2_Load(object sender, EventArgs e)
        {
            this.comboBox1.DataSource = setTables();
            this.comboBox1.DisplayMember = "name";
            this.comboBox1.ValueMember = "id";
            //connection.Open();
            //this.dataGridView1.DataSource = connection.GetSchema();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            connection.Open();
            this.dataGridView1.DataSource = connection.GetSchema(this.comboBox1.Text);
            connection.Close();
        }
    }
}

  

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 首先要明確一點的是502是怎麼出現的,為什麼會出現502呢?一般而言,出現502的錯誤是因為php-cgi連接數不夠導致的。舉個例子:php-cgi開10個進程,前端發20個請求,每個請求的腳本都sleep100s,那麼必然有至多10個請求會出現502錯誤。因此,出現502是因為php進程不夠用了, ...
  • ->系統當前狀態腳本 腳本內容如下: 實現效果如下: ->查看系統當前記憶體狀態 實現效果如下: [root@jumpserver-70 scripts]# sh mem.sh Memory Is OK 9% ->查看ip 是否暢通 ->創建用戶並設置密碼 ->安裝nginx->查看狀態 ->ngin ...
  • 1 首先設置你購買的雲盤配置,例如cpu,記憶體,磁碟類型、容量,網路類型等 2.阿裡雲可以使用瀏覽器進行遠程shell連接 首先需要輸入遠程密碼,第一次連接的時候會提示 一定要牢記 輸入密碼後進入shell界面 比較坑的是,假如你在購買阿裡雲伺服器時設置了初始root密碼,第一次登陸不起作用,提示l ...
  • 數據類型 (詳細數據類型請參考:http://www.runoob.com/mysql/mysql-data-types.html) 數字 整型 tinyint int bigint 小數: float 在小數點後 位數比較短的情況下不精準; double 在小數點後 位數比較長的情況下不精準 字元 ...
  • 一、資料庫備份 備份的目的: 備份: 能夠防止由於機械故障以及人為誤操作帶來的數據丟失,例如將資料庫文件保存在了其它地方。 冗餘: 數據有多份冗餘,但不等備份,只能防止機械故障還來的數據丟失,例如主備模式、資料庫集群。 備份過程中必須考慮因素:1. 數據的一致性2. 服務的可用性 二、物理備份 1、 ...
  • 一、資料庫備份 1.命令簡介: # mysqldump -h 伺服器 -u用戶名 -p密碼 資料庫名 > 備份文件.sql1)關於資料庫名: -A, --all-databases 所有庫 school 資料庫名 school stu_info t1 school 資料庫的表stu_info、t1 ...
  • 1.LOCATE函數 LOCATE(substr,str) 返回子串 substr 在字元串 str 中第一次出現的位置。如果子串 substr 在 str 中不存在,返回值為 0。如果substr或str為NULL,則返回NULL。(從1開始)。 例如: mysql> SELECT LOCATE( ...
  • 一、開啟二進位日誌 1)未開啟二進位日誌之前: 2)開啟二進位日誌 修改my.cnf並且將以下參數加入其中,重啟mysql實例: 重啟伺服器: 3)查看開啟狀態; 4)註意事項 在官方文檔中,說啟用binary log只是需要將log-bin=mysql-bin設置即可,但是因為有bug,所以必須要 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...