Monica Mona has Published 112 Answers

What is the difference between MySQL LOCATE() and FIND_IN_SET() functions?

Monica Mona
Published on 20-Feb-2018 07:04:02
As we know, both the functions are used to search a string from the arguments provided in them but there are some significant differences between them as followsFIND_IN_SET() function uses the string list that is itself a string containing the substring separated by commas. Whereas, LOCATE() function contains a string ... Read More

In MySQL, which function we can use to find the index position of a particular string from a list of strings?

Monica Mona
Published on 20-Feb-2018 05:55:13
We can use FIELD() function to find the index position of a particular string from a list of strings.SyntaxFIELD(str search, String1, String2, …StringN)Here, the str search is the string whose index number we want to search and String1, String …StringN is the list of strings from which the search would ... Read More

What MySQL CHAR_LENGTH() function returns if no parameter is provided to it?

Monica Mona
Published on 19-Feb-2018 13:23:39
In this case, it means we are providing an empty string as an argument to the CHAR_LENGTH() function. It will return 0 on providing empty string because there are no characters to be counted by CHAR_LENGTH() function.Examplemysql> Select CHAR_LENGTH(''); +-----------------+ | CHAR_LENGTH('') | +-----------------+ | 0         ... Read More

How can we use WHERE condition when creating a table with CTAS (Create Table as Selected) script?

Monica Mona
Published on 19-Feb-2018 10:29:24
As we know that we can copy the data and structure from an existing table by CTAS script. Use of WHERE clause is demonstrated in the example belowmysql> Create table EMP_BACKUP2 AS SELECT * from EMPLOYEE WHERE id = 300 AND Name = 'Mohan'; Query OK, 1 row affected (0.14 ... Read More

What is the significant difference between MySQL TRUNCATE and DROP command?

Monica Mona
Published on 19-Feb-2018 08:55:30
The most significant difference between MySQL TRUNCATE and DROP command is that TRUNCATE command will not destroy table’s structure but in contrast DROP command will destroy table’s structure too.Examplemysql> Create table testing(id int PRIMARY KEY NOT NULL AUTO_INCREMENT, Name Varchar(20)); Query OK, 0 rows affected (0.24 sec) mysql> Insert ... Read More

How to add columns to an existing MySQL table?

Monica Mona
Published on 19-Feb-2018 08:16:35
By using ALTER command we can add columns to an existing table.SyntaxAlter table table-name ADD (column-name datatype);Example In the example below, with the help of ALTER Command, column ‘GRADE’ is added to the table ‘Student’.mysql> Alter table Student ADD (Grade Varchar(10)); Query OK, 5 rows affected (1.05 sec) Records: 5 Duplicates: ... Read More

How Can I check the size of the tables in a particular MySQL database?

Monica Mona
Published on 19-Feb-2018 07:30:17
As we have checked the size of the MySQL database, similarly we can also check the size of tables in a particular database. It can be done as follows −mysql> SELECT     -> table_name AS "Table",     -> round(((data_length + index_length) / 1024 / 1024), 2) as SIZE ... Read More

Are MySQL database and table names case-sensitive?

Monica Mona
Published on 19-Feb-2018 06:53:34
Actually, the case sensitivity of database and table name depends a lot on the case sensitivity of the underlying operating system. Hence, we can say that such names are not case sensitive in Windows but are case sensitive in most varieties of Unix.

How can we assign FOREIGN KEY constraint on multiple columns?

Monica Mona
Published on 19-Feb-2018 06:19:22
MySQL allows us to add a FOREIGN KEY constraint on multiple columns in a table. The condition is that each Foreign Key in the child table must refer to the different parent table.ExampleSuppose we have a table ‘customer2’ which have a Primary Key constraint on the field ‘cust_unq_id’ as follows ... Read More

How to declare a variable in C++?

Monica Mona
Published on 16-Feb-2018 06:01:59
In C++, declaration and definition are often confused. A declaration means (in C) that you are telling the compiler about type, size and in case of function declaration, type and size of its parameters of any variable, or user-defined type or function in your program. No space is reserved in ... Read More
Previous 1 ... 3 4 5 6 7 8 9 ... 12 Next
Advertisements