- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一些 SQL 代码来创建我的表,其中所有列名都按字母顺序排列。我需要使用 SQL DATA LOADINFILE 加载的数据采用完全不同的格式。我可能有 1000 列需要重新排序以匹配我的 CSV。
我正在尝试找到一种自动执行此操作的方法。 SQL代码为:
CREATE TABLE rets_property_cnd (
`AgentCoListFirstName` VARCHAR(50) COMMENT 'Co-Listing Agent First Name',
`AgentCoListFullName` VARCHAR(75) COMMENT 'Co-Listing Agent Full Name',
`AgentCoListID` VARCHAR(8) COMMENT 'Co-Listing Agent ID ',
`AgentCoListLastName` VARCHAR(50) COMMENT 'Co-Listing Agent Last Name',
`AgentCoListPhone` VARCHAR(25) COMMENT 'Co-Listing Agent Phone',
`AgentListFirstName` VARCHAR(50) COMMENT 'Listing Agent First Name',
`AgentListFullName` VARCHAR(75) COMMENT 'Listing Agent Full Name',
`AgentListID` VARCHAR(8) COMMENT 'Listing Agent ID',
`AgentListLastName` VARCHAR(50) COMMENT 'Listing Agent Last Name',
`AgentListPhone` VARCHAR(25) COMMENT 'Listing Agent Phone',
`AppliancesOther` TEXT COMMENT 'Appliances Other',
`AreaID` VARCHAR(50) COMMENT 'Area',
`AssociationFee` INT(3) COMMENT 'Association Fee',
`AssociationFeeIncludes` TEXT COMMENT 'Association Fee Includes',
`BasementDesc` VARCHAR(50) COMMENT 'Basement Description',
`BasementType` VARCHAR(50) COMMENT 'Basement Type',
`BedroomFourDim` VARCHAR(5) COMMENT 'Bedroom 4 Dimensions',
`BedroomOneDesc` VARCHAR(50) COMMENT 'Bedroom 1 Description',
`BedroomOneDim` VARCHAR(5) COMMENT 'Bedroom 1 Dimensions',
`BedroomsBasement` INT(2) COMMENT 'Bedrooms Basement',
`BedroomsMain` INT(2) COMMENT 'Bedrooms Main',
`BedroomsOther` INT(2) COMMENT 'Bedrooms Other',
`BedroomsSecond` INT(2) COMMENT 'Bedrooms Second',
`BedroomsThird` INT(2) COMMENT 'Bedrooms Third',
`BedroomThreeDim` VARCHAR(5) COMMENT 'Bedroom 3 Dimensions',
`BedroomTwoDesc` VARCHAR(50) COMMENT 'Bedroom 2 Description',
`BedroomTwoDim` VARCHAR(5) COMMENT 'Bedroom 2 Dimensions',
`BuiltInfo` VARCHAR(50) COMMENT 'Built Information',
`City` VARCHAR(20) COMMENT 'City',
`CommunityAmenities` TEXT COMMENT 'Community Amenities',
`CompletionDate` DATE default '0000-00-00' not null COMMENT 'Completion Date',
`ConstructionType` VARCHAR(50) COMMENT 'Construction Type',
`ContingencyType` VARCHAR(50) COMMENT 'Contingency Type',
`CoolingSource` VARCHAR(50) COMMENT 'Cooling Source',
`CoolingSystem` VARCHAR(50) COMMENT 'Cooling System',
`CountyID` VARCHAR(50) COMMENT 'County',
`DenDesc` VARCHAR(50) COMMENT 'Den Description',
`DenDim` VARCHAR(5) COMMENT 'Den Dimensions',
`DiningRoomDesc` VARCHAR(50) COMMENT 'Dining Room Description',
`DiningRoomDim` VARCHAR(5) COMMENT 'Dining Room Dimensions',
`Directions` VARCHAR(255) COMMENT 'Directions',
`DrapesRemain` VARCHAR(50) COMMENT 'Drapes Remain',
`DrivewayType` VARCHAR(50) COMMENT 'Driveway Type',
`ElementarySchool` VARCHAR(50) COMMENT 'Elementary School',
`ElementarySchoolTwo` VARCHAR(50) COMMENT 'Elementary School 2',
`EnergyFeatures` TEXT COMMENT 'Green Features',
`ExteriorAlterations` CHAR(1) COMMENT 'Exterior Alterations',
`ExteriorTrim` VARCHAR(50) COMMENT 'Exterior Trim',
`FloorTypes` TEXT COMMENT 'Floor Types',
`FullBathsBasement` INT(2) COMMENT 'Full Baths Basement',
`FullBathsMain` INT(2) COMMENT 'Full Baths Main',
`FullBathsOther` INT(2) COMMENT 'Full Baths Other',
`FullBathsSecond` INT(2) COMMENT 'Full Baths Second',
`FullBathsThird` INT(2) COMMENT 'Full Baths Third',
`GarageCapacity` INT(1) COMMENT 'Garage Capacity',
`GarageDescription` VARCHAR(50) COMMENT 'Garage Description',
`GreenCertifyingBody` TEXT COMMENT 'Green Certifying Body',
`HalfBathsBasement` INT(2) COMMENT 'Half Baths Basement',
`HalfBathsMain` INT(2) COMMENT 'Half Baths Main',
`HalfBathsOther` INT(2) COMMENT 'Half Baths Other',
`HalfBathsSecond` INT(2) COMMENT 'Half Baths Second',
`HalfBathsThird` INT(2) COMMENT 'Half Baths Third',
`HandicapAccess` VARCHAR(50) COMMENT 'Handicap Accessible',
`HasPetRestriction` CHAR(1) COMMENT 'Has Pet Restriction',
`HeatingSource` VARCHAR(50) COMMENT 'Heating Source',
`HeatingSystem` VARCHAR(50) COMMENT 'Heating System',
`HighSchool` VARCHAR(50) COMMENT 'High School',
`HobbyRoomDesc` VARCHAR(50) COMMENT 'Hobby Room Description',
`HobbyRoomDim` VARCHAR(5) COMMENT 'Hobby Room Dimensions',
`InteriorOther` TEXT COMMENT 'Interior Other',
`IsCertifiedGreen` CHAR(1) COMMENT 'Certified Green Home',
`IsNewConstruction` CHAR(1) COMMENT 'New Construction',
`JuniorHighSchool` VARCHAR(50) COMMENT 'Junior High School',
`KitchenDesc` VARCHAR(50) COMMENT 'Kitchen Description',
`KitchenDim` VARCHAR(5) COMMENT 'Kitchen Dimensions',
`Latitude` DECIMAL(19,16) COMMENT 'Latitude',
`ListingStatusID` VARCHAR(50) COMMENT 'Listing Status',
`ListingType` VARCHAR(50) COMMENT 'Listing Type',
`ListPrice` INT(10) COMMENT 'List Price',
`LivingRoomDesc` VARCHAR(50) COMMENT 'Living Room Description',
`LivingRoomDim` VARCHAR(5) COMMENT 'Living Room Dimensions',
`Longitude` DECIMAL(19,16) COMMENT 'Longitude',
`MailboxType` VARCHAR(50) COMMENT 'Mailbox Type',
`MapNumber` VARCHAR(4) COMMENT 'Map Number',
`MediaUpdateDate` DATETIME default '0000-00-00 00:00:00' not null COMMENT 'Media Update Date',
`MiscOther` TEXT COMMENT 'Miscellaneous Other',
`MlsNum` VARCHAR(8) COMMENT 'MLS Number',
`ModDate` DATETIME default '0000-00-00 00:00:00' not null COMMENT 'Mod Date',
`NextOpenHouseDate` DATETIME default '0000-00-00 00:00:00' not null COMMENT 'NextOpenHouseDate',
`NumberOfFireplaces` INT(1) COMMENT 'Number Of Fireplaces',
`NumOfStories` DECIMAL(3,2) COMMENT 'Number Of Stories',
`OfficeCoListCode` VARCHAR(8) COMMENT 'Co-Listing Office Code',
`OfficeCoListCompanyID` VARCHAR(8) COMMENT 'Co-Listing Office Company ID',
`OfficeCoListID` VARCHAR(8) COMMENT 'Co-Listing Office ID',
`OfficeCoListOfficeName` VARCHAR(50) COMMENT 'Co-Listing Office Name',
`OfficeCoListPhone` VARCHAR(25) COMMENT 'Co-Listing Office Phone',
`OfficeListCode` VARCHAR(8) COMMENT 'Listing Office Code',
`OfficeListCompanyID` VARCHAR(8) COMMENT 'Listing Office Company ID',
`OfficeListID` VARCHAR(8) COMMENT 'Listing Office ID',
`OfficeListIsIDX` CHAR(1) COMMENT 'Listing Office Is IDX',
`OfficeListOfficeName` VARCHAR(50) COMMENT 'Listing Office Name',
`OfficeListPhone` VARCHAR(25) COMMENT 'Listing Office Phone',
`OpenHouseType` VARCHAR(50) COMMENT 'Open House',
`OtherRestrictions` TEXT COMMENT 'Other Restrictions',
`OtherRoomOneDesc` VARCHAR(50) COMMENT 'Other Room 1 Description',
`OtherRoomOneDim` VARCHAR(5) COMMENT 'Other Room 1 Dimensions',
`OtherRoomTwoDesc` VARCHAR(50) COMMENT 'Other Room 2 Description',
`OtherRoomTwoDim` VARCHAR(5) COMMENT 'Other Room 2 Dimensions',
`OvenDesc` VARCHAR(50) COMMENT 'Oven Description',
`OvenSource` VARCHAR(50) COMMENT 'Oven Source',
`PermitAvmUse` CHAR(1) COMMENT 'Permit AVM Use',
`PermitExternalComments` CHAR(1) COMMENT 'PermitExternalComments',
`PictureCount` INT(2) COMMENT 'Picture Count',
`PrimaryPictureURL` VARCHAR(65) COMMENT 'PrimaryPictureURL',
`PropertyClassID` VARCHAR(50) COMMENT 'Property Class',
`PropertySubType` VARCHAR(50) COMMENT 'Property Sub-Type',
`RangeDesc` VARCHAR(50) COMMENT 'Range Description',
`RangeSource` VARCHAR(50) COMMENT 'Range Source',
`RecRoomDesc` VARCHAR(50) COMMENT 'Rec Room Description',
`RecRoomDim` VARCHAR(5) COMMENT 'Rec Room Dimensions',
`Remarks` VARCHAR(255) COMMENT 'Public Remarks',
`RentingPermitted` CHAR(1) COMMENT 'Renting Permitted',
`RoofMaterial` VARCHAR(50) COMMENT 'Roofing Material',
`SecurityDesc` TEXT COMMENT 'Security Description',
`SewerSystem` VARCHAR(50) COMMENT 'Sewer System',
`SqFtBasement` INT(6) COMMENT 'Sq. Ft. Basement',
`SqFtMainFloor` INT(6) COMMENT 'Sq. Ft. Main Floor',
`SqFtMeasurementSource` VARCHAR(50) COMMENT 'Sq. Ft. Measurement Source',
`SqFtOther` INT(6) COMMENT 'Sq. Ft. Other',
`SqFtOtherDescription` VARCHAR(50) COMMENT 'Other Sq Ft Description',
`SqFtSecondFloor` INT(6) COMMENT 'Sq. Ft. Second Floor',
`SqFtThirdFloor` INT(6) COMMENT 'Sq. Ft. Third Floor',
`SqFtTotal` INT(6) COMMENT 'Sq. Ft. Total',
`State` VARCHAR(50) COMMENT 'State',
`StreetAddressDisplay` VARCHAR(75) COMMENT 'Street Address',
`StreetDirection` VARCHAR(50) COMMENT 'Street Direction',
`StreetLetter` VARCHAR(2) COMMENT 'Street Letter',
`StreetName` VARCHAR(26) COMMENT 'Street Name',
`StreetNumber` INT(10) COMMENT 'Street Number',
`Style` VARCHAR(50) COMMENT 'Style',
`Subdivision` VARCHAR(26) COMMENT 'Development',
`TaxAmount` INT(10) COMMENT 'Tax Amount',
`TotalBedrooms` INT(2) COMMENT 'Total Bedrooms',
`TotalFullBaths` INT(2) COMMENT 'Total Full Baths',
`TotalHalfBaths` INT(2) COMMENT 'Total Half Baths',
`TotalRooms` INT(2) COMMENT 'Total Rooms',
`TrailersPermitted` CHAR(1) COMMENT 'Trailers Permitted',
`UnitLocation` VARCHAR(50) COMMENT 'Unit Location',
`UnitNumber` VARCHAR(10) COMMENT 'Unit Number',
`VerticalLocation` VARCHAR(50) COMMENT 'Vertical Location',
`WaterfrontDesc` VARCHAR(50) COMMENT 'Waterfront Description',
`WaterfrontDock` VARCHAR(50) COMMENT 'Waterfront Dock',
`WaterSource` VARCHAR(50) COMMENT 'Water Source',
`WithdrawnDate` DATE default '0000-00-00' not null COMMENT 'Withdrawn Date',
`YearBuilt` INT(4) COMMENT 'Year Built',
`ZipCode` VARCHAR(5) COMMENT 'Zip Code',
PRIMARY KEY(`MlsNum`) );
我需要将上面的SQL重新排序成的新订单:
BedroomsThird
OtherRoomOneDesc
KitchenDim
BedroomTwoDim
Subdivision
OfficeListOfficeName
DiningRoomDim
CoolingSystem
OvenSource
OtherRoomOneDim
AgentCoListFullName
FloorTypes
PictureCount
HobbyRoomDim
BedroomFourDim
OfficeListPhone
FullBathsOther
UnitLocation
OtherRestrictions
SqFtOtherDescription
OfficeCoListOfficeName
SqFtTotal
OfficeListCompanyID
OvenDesc
ListingType
TotalFullBaths
HalfBathsBasement
InteriorOther
OfficeCoListPhone
AppliancesOther
GreenCertifyingBody
ListPrice
CountyID
OfficeListCode
BasementType
BedroomsBasement
HalfBathsThird
HeatingSystem
StreetLetter
RangeDesc
TotalHalfBaths
RentingPermitted
AreaID
BuiltInfo
HighSchool
PermitExternalComments
OfficeCoListID
YearBuilt
AgentListFirstName
Directions
CoolingSource
OfficeListIsIDX
NextOpenHouseDate
ElementarySchool
AgentCoListFirstName
LivingRoomDim
WaterfrontDesc
WaterSource
Remarks
AgentCoListID
ExteriorAlterations
City
ConstructionType
DiningRoomDesc
CommunityAmenities
MapNumber
OfficeListID
TrailersPermitted
TotalBedrooms
PropertyClassID
LivingRoomDesc
DenDesc
MailboxType
HalfBathsMain
OfficeCoListCode
PropertySubType
DrapesRemain
SqFtBasement
FullBathsMain
AgentListLastName
AgentCoListPhone
BedroomTwoDesc
OpenHouseType
FullBathsSecond
RecRoomDesc
SqFtSecondFloor
SewerSystem
BedroomsOther
ModDate
BedroomsSecond
StreetDirection
MlsNum
ExteriorTrim
JuniorHighSchool
IsNewConstruction
State
GarageCapacity
SqFtMeasurementSource
VerticalLocation
HalfBathsSecond
KitchenDesc
ElementarySchoolTwo
WaterfrontDock
HasPetRestriction
StreetAddressDisplay
DenDim
UnitNumber
OfficeCoListCompanyID
AgentListID
ZipCode
EnergyFeatures
OtherRoomTwoDesc
RangeSource
FullBathsBasement
RecRoomDim
TotalRooms
AgentListFullName
WithdrawnDate
BedroomOneDesc
AssociationFeeIncludes
Style
DrivewayType
OtherRoomTwoDim
HobbyRoomDesc
BedroomsMain
SecurityDesc
HandicapAccess
SqFtMainFloor
AgentCoListLastName
ListingStatusID
BedroomOneDim
MiscOther
IsCertifiedGreen
PrimaryPictureURL
NumOfStories
TaxAmount
SqFtThirdFloor
ContingencyType
StreetNumber
NumberOfFireplaces
BasementDesc
Latitude
AssociationFee
CompletionDate
PermitAvmUse
MediaUpdateDate
HeatingSource
RoofMaterial
FullBathsThird
SqFtOther
Longitude
StreetName
GarageDescription
HalfBathsOther
AgentListPhone
BedroomThreeDim
我最终使用命令行来执行此操作。这是我使用的:
mysqlimport -hHOSTNAMEm --user=USERNAME -pPASSWORD --ignore-lines=1 --fields-optionally-enclosed-by="\"" --fields-terminated-by=, --lines-terminated-by="\n" --local DBANAME rets_property_cnd.csv -c BedroomsThird,OtherRoomOneDesc,KitchenDim,BedroomTwoDim,Subdivision,OfficeListOfficeName,DiningRoomDim,CoolingSystem,OvenSource,OtherRoomOneDim,AgentCoListFullName,FloorTypes,PictureCount,HobbyRoomDim,BedroomFourDim,OfficeListPhone,FullBathsOther,UnitLocation,OtherRestrictions,SqFtOtherDescription,OfficeCoListOfficeName,SqFtTotal,OfficeListCompanyID,OvenDesc,ListingType,TotalFullBaths,HalfBathsBasement,InteriorOther,OfficeCoListPhone,AppliancesOther,GreenCertifyingBody,ListPrice,CountyID,OfficeListCode,BasementType,BedroomsBasement,HalfBathsThird,HeatingSystem,StreetLetter,RangeDesc,TotalHalfBaths,RentingPermitted,AreaID,BuiltInfo,HighSchool,PermitExternalComments,OfficeCoListID,YearBuilt,AgentListFirstName,Directions,CoolingSource,OfficeListIsIDX,NextOpenHouseDate,ElementarySchool,AgentCoListFirstName,LivingRoomDim,WaterfrontDesc,WaterSource,Remarks,AgentCoListID,ExteriorAlterations,City,ConstructionType,DiningRoomDesc,CommunityAmenities,MapNumber,OfficeListID,TrailersPermitted,TotalBedrooms,PropertyClassID,LivingRoomDesc,DenDesc,MailboxType,HalfBathsMain,OfficeCoListCode,PropertySubType,DrapesRemain,SqFtBasement,FullBathsMain,AgentListLastName,AgentCoListPhone,BedroomTwoDesc,OpenHouseType,FullBathsSecond,RecRoomDesc,SqFtSecondFloor,SewerSystem,BedroomsOther,ModDate,BedroomsSecond,StreetDirection,MlsNum,ExteriorTrim,JuniorHighSchool,IsNewConstruction,State,GarageCapacity,SqFtMeasurementSource,VerticalLocation,HalfBathsSecond,KitchenDesc,ElementarySchoolTwo,WaterfrontDock,HasPetRestriction,StreetAddressDisplay,DenDim,UnitNumber,OfficeCoListCompanyID,AgentListID,ZipCode,EnergyFeatures,OtherRoomTwoDesc,RangeSource,FullBathsBasement,RecRoomDim,TotalRooms,AgentListFullName,WithdrawnDate,BedroomOneDesc,AssociationFeeIncludes,Style,DrivewayType,OtherRoomTwoDim,HobbyRoomDesc,BedroomsMain,SecurityDesc,HandicapAccess,SqFtMainFloor,AgentCoListLastName,ListingStatusID,BedroomOneDim,MiscOther,IsCertifiedGreen,PrimaryPictureURL,NumOfStories,TaxAmount,SqFtThirdFloor,ContingencyType,StreetNumber,NumberOfFireplaces,BasementDesc,Latitude,AssociationFee,CompletionDate,PermitAvmUse,MediaUpdateDate,HeatingSource,RoofMaterial,FullBathsThird,SqFtOther,Longitude,StreetName,GarageDescription,HalfBathsOther,AgentListPhone,BedroomThreeDim
在 mysqlimport 的语法中,我一直遗漏了一个技巧。 CSV 文件的名称必须与您的表格相同。
最佳答案
您不能只在 LOAD DATA 中指定列顺序吗?声明?
关于mysql - 以编程方式重新排序 SQL 列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12291964/
SQL、PL-SQL 和 T-SQL 之间有什么区别? 谁能解释一下这三者之间的区别,并提供每一个的相关使用场景? 最佳答案 SQL 是一种对集合进行操作的查询语言。 它或多或少是标准化的,几乎所有关
这个问题已经有答案了: What is the difference between SQL, PL-SQL and T-SQL? (6 个回答) 已关闭 9 年前。 我对 SQL 的了解足以完成我的
我在数据库中有一个 USER 表。该表有一个 RegistrationDate 列,该列有一个默认约束为 GETDATE()。 使用 LINQ 时,我没有为 RegistrationDate 列提供任
我有一个可能属于以下类型的字符串 string expected result 15-th-rp 15 15/12-rp 12 15-12-th
很难说出这里问的是什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或言辞激烈,无法以目前的形式合理回答。如需帮助澄清此问题以便可以重新打开,visit the help center . 9年前关闭
我有一个存储过程(称为 sprocGetArticles),它从文章表中返回文章列表。这个存储过程没有任何参数。 用户可以对每篇文章发表评论,我将这些评论存储在由文章 ID 链接的评论表中。 有什么方
我目前正在做一个 *cough*Oracle*cough* 数据库主题。讲师介绍embedded SQL作为让其他语言(例如 C、C++)与(Oracle)数据库交互的方式。 我自己做了一些数据库工作
SQL Server 中 SQL 语句的最大长度是多少?这个长度是否取决于 SQL Server 的版本? 例如,在 DECLARE @SQLStatement NVARCHAR(MAX) = N'S
这个问题已经有答案了: Simple way to transpose columns and rows in SQL? (9 个回答) 已关闭 8 年前。 CallType
预先感谢您对此提供的任何帮助。 假设我有一个查询,可以比较跨年的数据,从某个任意年份开始,永无止境(进入 future ),每年同一时期直到最后一个完整的月份(其特点是一月数据永远不会显示至 2 月
我在数据库中有一个 USER 表。该表有一个 RegistrationDate 列,该列的默认约束为 GETDATE()。 使用 LINQ 时,我没有为 RegistrationDate 列提供任何数
下面是我试图用来检查存储过程是否不存在然后创建过程的 sql。它会抛出一个错误:Incorrect syntax near the keyword 'PROCEDURE' IF NOT EXISTS
我有一个同事声称动态 SQL 在许多情况下比静态 SQL 执行得更快,所以我经常看到 DSQL 到处都是。除了明显的缺点,比如在运行之前无法检测到错误并且更难阅读,这是否准确?当我问他为什么一直使用
来自 lobodava 的动态 SQL 查询是: declare @sql nvarchar(4000) = N';with cteColumnts (ORDINAL_POSITION, CO
使用 SQL Server 中的存储过程执行动态 SQL 命令的现实优点和缺点是什么 EXEC (@SQL) 对比 EXEC SP_EXECUTESQL @SQL ? 最佳答案 sp_executes
我有这个有效的 SQL 查询: select sum(dbos.Points) as Points, dboseasons.Year from dbo.StatLines dbos i
我正在调试一些构建成功运行的 SQL 命令的代码。 然而,在查询结束时,查询结果似乎被写入了一个文本文件。 完整的查询如下 echo SELECT DATE,DATETABLE,DATE,APPDAT
我有一些创建表的 .sql 文件(MS SQL 数据库): 表_1.sql: IF OBJECT_ID (N'my_schema.table1', N'U') IS NOT NULL DROP TAB
我写了下面的 SQL 存储过程,它一直给我错误@pid = SELECT MAX(... 整个过程是: Alter PROCEDURE insert_partyco @pname varchar(20
我在 SQL Server 2005 中有包含两列 Fruit 和 Color 的表,如下所示 Fruit Colour Apple Red Orange
我是一名优秀的程序员,十分优秀!