Remove Primary Key and Auto Increment from MySQL Column

George John
Updated on 30-Jul-2019 22:30:24

3K+ Views

You can use ALTER command to remove primary key and auto_increment. The syntax is as follows −ALTER TABLE yourTableName DROP PRIMARY KEY, change yourColumnName yourColumnName data type;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table removePrimaryKey    -> (    -> StudentId int NOT NULL AUTO_INCREMENT,    -> StudentFirstName varchar(20),    -> StudentLastName varchar(20),    -> PRIMARY KEY(StudentId)    -> ); Query OK, 0 rows affected (0.47 sec)Check the description of table using DESC command. The syntax is as follows −desc yourTableName;Check the description of the table ... Read More

Keep Connection Alive in MySQL Workbench

Chandu yadav
Updated on 30-Jul-2019 22:30:24

898 Views

To keep connection alive in MySQL Workbench, you need to reach at the following location −Edit -> Preferences -> SQL EditorHere is the snapshot of all the options.After clicking the “Edit” menu, we will select “Workbench Preferences” as shown below −Now, select SQL Editor and set an interval. You can also set the below options to set the connection alive in MySQL Workbench.DBMS connection Keep-alive intervalDBMS connection Read-timeout intervalDBMS connection Timeout intervalHere is the screenshot

Insert Multiple Rows with Single MySQL Query

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:24

415 Views

You can insert multiple rows with the help of values() separated by comma(, ). The syntax is as follows −insert into yourTableName values(value1, value2, ...N), (value1, value2, ...N), (value1, value2, ...N), (value1, value2, ...N), (value1, value2, ...N), (value1, value2, ...N)................N;To insert multiple rows, let us create a table. The following is the query to create a table −mysql> create table MultipleRowsInsert    −> (    −> UserId int,    −> UserName varchar(200)    −> ); Query OK, 0 rows affected (1.21 sec)Here is the query to insert multiple rows in the table −mysql> insert into MultipleRowsInsert values(100, 'Bob'), (101, 'Smith'), ... Read More

Abstract Base Classes in Python (ABC)

George John
Updated on 30-Jul-2019 22:30:24

11K+ Views

A class is called an Abstract class if it contains one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and its abstract methods must be implemented by its subclasses.Abstract base classes provide a way to define interfaces when other techniques like hasattr() would be clumsy or subtly wrong (for example with magic methods). ABCs introduce virtual subclasses, which are classes that don’t inherit from a class but are still recognized by isinstance() and issubclass() functions. There are many built-in ABCs in Python. ABCs for Data ... Read More

Basics of Discrete Event Simulation Using SimPy in Python

Samual Sam
Updated on 30-Jul-2019 22:30:24

669 Views

SimPy (rhymes with “Blimpie”) is a python package for process-oriented discrete-event simulation.InstallationThe easiest way to install SimPy is via pip:pip install simpyAnd the output you may get will be something like, At the time of writing, simpy-3.0.11 is the most recent version of SimPy, and we will use it for all the below examples.In case, SimPy is already installed, use the –U option for pip to upgrade.pip install –U simpyNote: You need to have python 2.7 or above version and for Linux/Unix/MacOS you may need root privileges to install SimPy.To check if SimPy was successfully installed, open a python shell ... Read More

Return Order of MySQL SHOW COLUMNS

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

344 Views

To return order of MySQL SHOW COLUMNS, you need to use ORDER BY clause. The syntax is as follows −SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = ‘yourTableName’ AND column_name LIKE 'yourStartColumnName%' ORDER BY column_name DESC;Let us create a table in database TEST. The query to create a table is as follows −mysql> create table OrderByColumnName -> ( -> StudentId int, -> StudentFirstName varchar(10), -> StudentLastName varchar(10), -> StudentAddress varchar(20), -> StudentAge int, -> StudentMarks int ... Read More

Python Binary Data Services

Ankith Reddy
Updated on 30-Jul-2019 22:30:24

409 Views

Provisions of the struct module in the Python library are useful in performing conversions between C type structs and Python bytes objects. This can be achieved by module level functions as well as Struct class and its methods as defined in the struct module.The conversion functions use a format string. The byte order, size, and alignment used in the format string is determined by formatting character as per the following tableCharacterByte orderSizeAlignment@nativenativenative=nativestandardnonebig-endianstandardnone!network (= big-endian)standardnoneFollowing table shows format characters used to denote C type variables and corresponding Python types.FormatC TypePython typexpad byteno valueccharbytes of length 1b/Bsigned/unsigned charinteger?_Boolboolh/Hshort/unsigned shortintegeri/Iint/unsigned intintegerl/Llong/unsigned longintegerffloatfloatddoublefloatschar[]bytespchar[]bytesPvoid *integerFollowing ... Read More

Update Field to Add Value to Existing Value in MySQL

Arjun Thakur
Updated on 30-Jul-2019 22:30:24

8K+ Views

You can update field to add value to an existing value with the help of UPDATE and SET command. The syntax is as follows −UPDATE yourTableName SET yourColumnName = yourColumnName+integerValueToAdd WHERE yourCondition;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table addingValueToExisting    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(30),    -> GameScore int,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.58 sec)Insert records in the table using insert command. The query is as follows −mysql> insert ... Read More

Python vs Ruby: Which One to Choose

Sai Subramanyam
Updated on 30-Jul-2019 22:30:24

146 Views

First thing comes in my mind, why to compare these two language only? This may be because both are interpreted, agile languages with an object oriented philosophy and very huge communities support. However, though both languages share some ideas, syntax elements and have almost the same features the two communities have nothing in common.Both the languages are very popular among the developer’s community (This is also one of the reasons to compare). Below are the top ten most popular languages in 2018 on GitHub based on opened pull request −Top 10 most popular languages on GitHub based on opened pull ... Read More

Format Hour in H (0-23) Format in Java

Samual Sam
Updated on 30-Jul-2019 22:30:24

394 Views

The “H” format in Java Date is like 0, 1, 2, 3, … 23 hour. Use SimpleDateFormat("H") to get the same format.// displaying hour in H format SimpleDateFormat simpleformat = new SimpleDateFormat("H"); String strHour = simpleformat.format(new Date()); System.out.println("Hour in H format = "+strHour);Above, we have used the SimpleDateFormat class, therefore the following package is imported −import java.text.SimpleDateFormat;The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time ... Read More

Advertisements