标签:企业 select ryu username 库文件 包含 component cap rms
/* 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(); } } }
标签:企业 select ryu username 库文件 包含 component cap rms
原文地址:https://www.cnblogs.com/geovindu/p/9675372.html