mysql

Mysql changing default engine

余生长醉 提交于 2021-02-16 19:44:54
问题 How to change the mysql engine to MYISAM. Now I am having mysql with INNODB but I want to change the engine to MYISAM. What i have to do? CREATE TABLE `classifieds_category` ( `id` int(11) NOT NULL AUTO_INCREMENT, `site_id` int(11) NOT NULL, `template_prefix` varchar(200) NOT NULL, `name` varchar(200) NOT NULL, `slug` varchar(50) NOT NULL, `enable_contact_form_upload` tinyint(1) NOT NULL DEFAULT '0', `contact_form_upload_max_size` int(11) NOT NULL DEFAULT '1048576', `contact_form_upload_file

MySQL日期和时间类型笔记

余生颓废 提交于 2021-02-16 19:28:14
最近在看《MySQL技术内幕:SQL编程》并做了笔记,这是一篇笔记类型博客,分享出来方便自己复习,也可以帮助其他人 一、日期时间类型所占空间对比 各种日期时间数据类型所占的空间: 类型 所占空间 DATETIME 8字节 DATE 3字节 TIMESTAMP 4字节 YEAR 1字节 TIME 3字节 二、DATETIME和DATE对比 DATETIME占用8字节,既显示了日期也显示时间,可以表示的日期范围为“1000-01-01 00:00:00”到“9999-12-31 23:59:59” DATE占用3字节,只显示日期,不显示具体时间,可显示的日期范围为“1000-01-01”到“9999-12-31” ok,这里特意介绍一下TIMESTAMP秒的小数部分问题 备注:5.6.4+版本才支持秒的小数部分,之前版本是不支持的 # 查询MySQL版本 select version(); # 建表验证问题 create table t (a datetime); # 写数据秒后面加上小数 insert into t select '2019-10-11 17:16:12.55555'; # 查询,发现并没有查出秒之后的小数 select * from t ; # 使用microsecond,读取秒之后的小数 select microsecond('2019-10-11 17:16

MySQL数据类型之日期和时间类型

爱⌒轻易说出口 提交于 2021-02-16 19:27:52
MySQL中拥有五种时间类型: YEAR 、 DATE 、 TIME 、 DTAETIME 、 TIMESTAMP 。 类型名称 日期格式 日期范围 存储需求 YEAR YYYY 1901 ~ 2155 或 0000 1个字节 DATE YYYY-MM-DD 1000-01-01 ~ 9999-12-3 3个字节 TIME HH:MM:SS -838:59:59 ~ 838:59:59 3个字节 DATETIME YYYY-MM-DD HH:MM:SS 1000-01-01 00:00:00 ~ 9999-12-31 23:59:59 8个字节 TIMESTAMP YYYY-MM-DD HH:MM:SS 1980-01-01 00:00:01 UTC ~ 2038-01-19 03:14:07 UTC 4个字节 来源: oschina 链接: https://my.oschina.net/u/3057088/blog/3103844

Why is fputcsv producing duplicate columns?

送分小仙女□ 提交于 2021-02-16 19:06:26
问题 I am adding a download button to a WordPress site that will query our database, and offer up the result as a CSV. Everything works, except the CSV produced has a duplicate column for each column it returns. We have checked the SQL query and it does not have duplicates. Here's how we are generating the CSV: $rows = //Call to SQL query function $fp = fopen('php://output', 'w'); fputcsv($fp, array_keys($rows)); foreach ($rows as $row) { fputcsv($fp, $row); } $filename = "EventResults.csv";

Why is fputcsv producing duplicate columns?

不羁岁月 提交于 2021-02-16 19:00:46
问题 I am adding a download button to a WordPress site that will query our database, and offer up the result as a CSV. Everything works, except the CSV produced has a duplicate column for each column it returns. We have checked the SQL query and it does not have duplicates. Here's how we are generating the CSV: $rows = //Call to SQL query function $fp = fopen('php://output', 'w'); fputcsv($fp, array_keys($rows)); foreach ($rows as $row) { fputcsv($fp, $row); } $filename = "EventResults.csv";

mysql 时间处理

懵懂的女人 提交于 2021-02-16 18:38:41
毫秒时间戳格式化: FROM_UNIXTIME(create_time/1000,'%Y年%m月%d日 %H:%i:%s') 获取时间差返回秒 TIMESTAMPDIFF(SECOND, '2019-1-3 18:32:55', CURRENT_TIMESTAMP()) 获取零点时间戳 昨天: UNIX_TIMESTAMP(CAST(SYSDATE()AS DATE) - INTERVAL 1 DAY) 今天:UNIX_TIMESTAMP(CAST(SYSDATE()AS DATE)) 要查询今天内的记录只要创建时间大于等于今天0点的时间戳就可以(仅限没有创建时间大于今天的情况),昨天内的记录就是大于等于昨天0点小于今天0点。 来源: oschina 链接: https://my.oschina.net/u/2507499/blog/2996602

Install MySQL 5.6 on Ubuntu 20.04

微笑、不失礼 提交于 2021-02-16 18:32:52
问题 I have a custom app that required MySql 5.6. I was able to install MySql 5.7 on ubuntu 20.04 using this tutorial: https://askubuntu.com/a/1232993 How can I install MySql 5.6 on ubuntu 20.04? Because the above tutorial only works for MySql 5.7, and I didn't find any working solution online. Can MySql 5.6 run on Ubuntu 20.04? Should I downgrade the OS to Ubuntu 18.04? 回答1: To install mysql 5.6.48 in Ubuntu 20: Download mysql from here unzip the tar file and install tar xvf mysql-server_5.6.48

Install MySQL 5.6 on Ubuntu 20.04

不羁的心 提交于 2021-02-16 18:27:58
问题 I have a custom app that required MySql 5.6. I was able to install MySql 5.7 on ubuntu 20.04 using this tutorial: https://askubuntu.com/a/1232993 How can I install MySql 5.6 on ubuntu 20.04? Because the above tutorial only works for MySql 5.7, and I didn't find any working solution online. Can MySql 5.6 run on Ubuntu 20.04? Should I downgrade the OS to Ubuntu 18.04? 回答1: To install mysql 5.6.48 in Ubuntu 20: Download mysql from here unzip the tar file and install tar xvf mysql-server_5.6.48

How to print table data index in RecursiveArrayIterator

左心房为你撑大大i 提交于 2021-02-16 18:27:10
问题 I want to print a table with index and I'm currently new to PDO and recursive table printing (is that what it's called?). I found a sample code to do that but it didn't print the index together with the data. So I modified the code to include index. However, I'm using Global Variable and from what I understand, it is a bad practice to use global variable. Is that so? Any other way to do it? <?php echo "<table id='DataTable1' class='display' cellspacing='0' width='100%'>"; echo "<tr><th>No</th

How to print table data index in RecursiveArrayIterator

柔情痞子 提交于 2021-02-16 18:26:25
问题 I want to print a table with index and I'm currently new to PDO and recursive table printing (is that what it's called?). I found a sample code to do that but it didn't print the index together with the data. So I modified the code to include index. However, I'm using Global Variable and from what I understand, it is a bad practice to use global variable. Is that so? Any other way to do it? <?php echo "<table id='DataTable1' class='display' cellspacing='0' width='100%'>"; echo "<tr><th>No</th