It is possible for the user to forget the name of the database or table or the structure of table or the name of the columns. This issue can be solved using MySQL since it supports many statements that provide information about the databases and tables which it supports.The ‘SHOW DATABASES’ query can be used to list all the databases that are managed by the server. To see which database is currently in use, the ‘DATABASE()’ function.Let us understand this query in the below section −Querymysql> SELECT DATABASE();Output+---------------------+ | DATABASE() | +---------------------+ | databaseInUse ... Read More
Let us understand how to list down all the tables in a MySQL database −Once a database is created, we can access and use a specific database, using the following query −Querymysql> USE databaseName Database changedThe ‘USE’ statement doesn’t require a semi-colon. This is similar to the ‘QUIT’ statement. Even if semi-colon is used, it does no harm. We can create and use a database of our own, but before that, MySQL administrator’s permission is required.The MySQL administrator can execute a command as shown below to provide permissions −mysql> GRANT ALL ON tableName.* TO ‘your_mysql_name’@’your_client_host’;Here, ‘your_mysql_name’ refers to the MySQL ... Read More
Let us understand how MySQL can be connected to the database using the command-line. This is done for clients like mysql or mysqldump.The below command invokes mysql without specifying any explicit connection parameters −mysqlSince there are no parameter options, the default values will be applied −The default host name is localhost.The default user name is ODBC on Windows.No password is sent because neither --password nor -p has been mentioned.For mysql, the first non-option argument is considered the name of the default database. Since there is no such argument, mysql selects no default database.To specify the host name, user name and ... Read More
We need to use the MAX(columnName) to find the Maximum value in a column, whereas use the MIN(columnName) to find the Maximum value in a column.Let’s say following is the syntax to find the highest and lowest value in a specific column −mysql> SELECT @min_val:=MIN(columnName), @max_val:=MAX(columnName) FROM tableName; mysql> SELECT * FROM tableName WHERE columnName=@min_val OR columnName=@max_val;Note: Let’s say we have a database named ‘StudentsRecords’ and a table named ‘STUDENT.Following is our table −StudentIdStudentMarksS00190S00297S00372We will now write the query −Querymysql> SELECT @min_val:=MIN(StudentMarks), @max_val:=MAX(StudentMarks) FROM STUDENT; mysql> SELECT * FROM STUDENT WHERE StudentMarks =@min_val OR StudentMarks =@max_val;Output+---------------------+ | StudentMarks ... Read More
ProblemExplain the concept of reference and pointer in a c programming language using examples.ReferenceIt is the alternate name for the variable that we declared.It can be accessed by using pass by value.It cannot hold the null values.Syntaxdatatype *variablenameFor example, int *a; //a contains the address of int type variable.PointerIt stores the address of variable.We can hold the null values using pointer.It can be access by using pass by reference.No need of initialization while declaring the variable.Syntaxpointer variable= & another variable;Example Live Demo#include int main(){ int a=2, b=4; int *p; printf("add of a=%d", &a); printf("add of b=%d", &b); ... Read More
ProblemWhat are the limitations of C Programming when compared to other programming languages?SolutionC Language prevents or prohibits the concepts of object-oriented programming language like inheritance, polymorphism, encapsulation, and data abstraction.C programming language does not detect errors for every line of coding, it will check the bugs after the complete coding is done.It does not exhibit namespace property.C programming has an insufficient level for data abstraction, i.e., does not have very large data handling capacity.C Language does not allow the user to detect the errors with the help of exception handling features.The constructor and destructors concept is not supported by the ... Read More
Let us understand how to find the row that holds the maximum of a specific column in MySQL −Note: We assume we have created a database named ‘DBNAME’ and a table named ‘tableName’.Let us see how to fetch the row that holds the maximum value of a specific column using a MySQL query −This can be done using the subquery. Here, we are fetching the maximum value of colName3 −QuerySELECT colName1, colName2, colName3 FROM tableName WHERE colName3=(SELECT MAX(colName3) FROM tableName);Output+--------------+--------------+--------------+ | colName1 | colName2 | colName3 | +--------------+--------------+--------------+ ... Read More
We need to use the MAX(columnName) to find the Maximum value in a column. But, at first, we will understand about database and tables in MySQL.Before installing MySQL, it is important to determine which version and which distribution format (it could be a binary file or from source files) should be used. If the database was newly created, it is obvious that there would be no tables in it.One of the most important part is to decide the structure of the database, the tables that would be needed, the columns in every table and the relationship between these tables. Once ... Read More
Let us understand how to use MySQL wth Apache −Apache is a web server software which is developed and maintained by Apache software foundation. It is a software that takes requests from user to access a web page.A few security checks are performed on the HTTP request and then takes the user to the web page. There are many programs that allow authentication of the users from a MySQL database. These programs can also be used to write the log files into a MySQL table.The Apache logging format can be easily changed into readable mode by using MySQL, and putting ... Read More
MySQL can be run in batch mode. To perform this, the statements that need to be executed should be put in a file and then ‘mysql’ should be indicated to read the input from this file. It can be done as shown below −shell> mysql < batch−fileIf mysql is running on Windows, and there are certain special characters on the file that could potentially create problems, the below line of code can be run −C:\> mysql −e "source batch−file"If the connection parameters need to be specified on the command line, the below line of code needs to be executed −shell> ... Read More