PHP: maximum execution time when importing .SQL data file (Maximum execution time of 300 seconds exceeded)

When you install first-time XAMPP and import a large file in the database the that if Maximum execution time of 300 seconds exceeded will be showing this type of error in your database:

So, There’s a configuration variable within the phpMyAdmin directory that you can find in below path-

“C:\xampp\phpMyAdmin\libraries\config.default.php”

after find this below line-

“$cfg[‘ExecTimeLimit’] = 300;”

and replace below line-

“$cfg[‘ExecTimeLimit’] = 0;”

that you can set to whatever maximum execution time you need. After that your problem will be solved.

Tagged : / / / /

SQL Queries

Β πŸ‘‰Β  To give a table, or a column in a table, a temporary name we can use Alias:

Syntax: SELECT "column_name" AS "column_Alias" FROM "table_name";

For example we have a table with column_name as “SNo” , “Country” and “Capital” and we want to update it as “Serial Number” , “State” and “Country_Capital then we will run the following command:

πŸ‘‰ To count the number of rows in the table:

Syntax: SELECT COUNT(column_name) AS (alias_name) FROM table_name;

For example we want to count number of orders placed by a particular customer from customer_table:

This will show the count of numbers of order places by the customer id “CG-1234′ and the products ordered.

πŸ‘‰ To add the values in a columns we use Sum command:

Syntax: SELECT SUM (column_name) FROM table_name;

For example we want to add the profit amount from the sales table:

πŸ‘‰ To find out an average for a column in the table:

Syntax: SELECT AVG (column_name) FROM table_name;

For example we need to find the average age of the customers from customer table:

πŸ‘‰To find the minimum and the maximum value in a table:

  • Minimum
SELECT MIN (column_name) FROM table_name;

For example we want to find the minimum order sale made for a product from sales table:

  • Maximum
SELECT MAX (column_name) FROM table_name;

For example we want to find the maximum order sale made for a product from sales table:

πŸ‘‰ To groups rows that have the same values into summary rows, like “find the number of customers in each region” we use GROUP BY statement. The GROUP BY statement is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result-set by one or more columns.

Syntax: SELECT "column_name","function-type" (column_name) FROM table_name Group By "column-name";

For example we need to find the number orders places in each region in the table:

πŸ‘‰ To make conditions for aggregate functions we use HAVING clause. The difference between Having clause and Where clause is that we cannot make conditions in aggregate functions whereas we can make conditions in aggregate functions using Having clause.

Syntax: SELECT column_name, AGGREGATE FUNCTION column_name FROM tables GROUP BY (column1) HAVING condition;

For example we have some set of customers in four regions and we want to see in which region the count of customers is more than 200. In this scenario we will use the HAVING clause and set a condition of count more than 200.

This command will show the count of customers in the regions where it is more than 200.

πŸ‘‰ To go through a condition and return a value when the first condition is met (like an if-then-else statement) “CASE” statement is used. So, once a condition is true, it will stop reading and return the result. If no conditions are true, it returns the value in theΒ ELSEΒ clause.

Syntax: SELECT * CASE WHEN condition THEN result ELSE result END;
Tagged : / / / / / / /

SQL files execute : Incorrect syntax near ‘go’.

saiki created the topic: SQL files execute : Incorrect syntax near ‘go’.
Getting below issue when trying to run the ant script.

I am trying to run few sql files from the folder through ant script in which I configured the “jtds-1.2.5.jar”.
Unable to run the GO statment in the sql file. But able to execute same file it through sql studio with out any error.

************************************************** **


************************************************** **
ERROR:
************************************************** **
java.sql.SQLException: Incorrect syntax near ‘go’.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnos tic(SQLDiagnostic.java:368)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(Td sCore.java:2820)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCor e.java:2258)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(T dsCore.java:632)
at net.sourceforge.jtds.jdbc.JtdsStatement.processRes ults(JtdsStatement.java:584)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL (JtdsStatement.java:546)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeImp l(JtdsStatement.java:723)
at net.sourceforge.jtds.jdbc.JtdsStatement.execute(Jt dsStatement.java:1160)
at org.apache.tools.ant.taskdefs.SQLExec.execSQL(SQLE xec.java:775)
at org.apache.tools.ant.taskdefs.SQLExec.runStatement s(SQLExec.java:751)
at org.apache.tools.ant.taskdefs.SQLExec$Transaction. runTransaction(SQLExec.java:1055)
at org.apache.tools.ant.taskdefs.SQLExec$Transaction. access$000(SQLExec.java:985)
at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLE xec.java:653)

rajeshkumar replied the topic: Re: SQL files execute : Incorrect syntax near ‘go’.
ave you tried executing sql statement on command line. may be sql studio has some setting which is helping to get it execute but not the ant script.

please refer these url as well…
forums.oracle.com/forums/thread.jspa?threadID=1323298
stackoverflow.com/questions/6614544/how-…on-using-jdbc-driver
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

saiki replied the topic: Re: SQL files execute : Incorrect syntax near ‘go’.
I Have set delimetr to GO in ant script

Then it worked

Tagged :

Compile sql file for syntax for error

saiki created the topic: Compile sql file for syntax for error
Hi,

How to Compile sql file for syntax error using ANT script.

Is there any possibility to compile through batch file.

I have 100 of sql file i dont want to create db and know the error in file.

Like java i want to compile it

rajeshkumar replied the topic: Re: Compile sql file for syntax for error
One way – exec method where you can mysqld and do whatever you want.
ant.apache.org/manual/Tasks/exec.html

Another way
www.roseindia.net/tutorials/ant/AntScriptCreateMysqlTable.shtml

Please try any of these and let me if you have any issues in script.
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

saiki replied the topic: Re: Compile sql file for syntax for error
Currently we are creating database through ant script only from CI. We do this build for every 8hrs.

Problem is b4 running the build we are deleting the existing database and then creating the new DB with same name. If there are any syntax error in the sql file the build fails and then it takes some time to fix it.

Idea is to compile sql (Check for syntax error) file for every 3hrs rather than executing and creating new DB and data ?

Tagged :