def _copyTable(syn, entity, destinationId, setAnnotations=False):
    """
    Copies synapse Tables

    :param entity:          A synapse ID of Table Schema

    :param destinationId:   Synapse ID of a project that the Table wants to be copied to

    :param setAnnotations:  Set the annotations of the copied table to be the annotations of the entity
                            Defaults to False
    """

    print("Getting table %s" % entity)
    myTableSchema = syn.get(entity)
    #CHECK: If Table name already exists, raise value error
    search = syn.query('select name from table where projectId == "%s"' % destinationId)
    for i in search['results']:
        if i['table.name'] == myTableSchema.name:
            raise ValueError('A table named "%s" already exists in this location. Table could not be copied'%myTableSchema.name)

    d = syn.tableQuery('select * from %s' % myTableSchema.id)
    d = d.asDataFrame()
    d = d.reset_index()
    del d['index']

    colIds = myTableSchema.columnIds

    newTableSchema = Schema(name = myTableSchema.name,
                           parent = destinationId,
                           columns=colIds)
    if setAnnotations:
        newTableSchema.annotations = myTableSchema.annotations

    if len(d) > 0:
        print("Created new table using schema %s" % newTableSchema.name)
        newTable = Table(schema=newTableSchema,values=d)
        newTable = syn.store(newTable)
        return(newTable.schema.id)
    else:
        print("No data, so storing schema %s" % newTableSchema.name)
        newTableSchema = syn.store(newTableSchema)
        return(newTableSchema.id)

#copy link
dataset/ETHPy150Open Sage-Bionetworks/synapsePythonClient/synapseutils/copy.py/_copyTable/original